How to use the teen_process.exec function in teen_process

To help you get started, we’ve selected a few teen_process examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github appium / appium-adb / lib / tools / apk-signing.js View on Github external
const getApksignerOutput = async (apksignerPath) => {
    let binaryPath = apksignerPath;
    if (system.isWindows() && util.isSubPath(binaryPath, originalFolder)) {
      // Workaround for https://github.com/nodejs/node-v0.x-archive/issues/25895
      binaryPath = path.basename(binaryPath);
    }
    const {stdout, stderr} = await exec(binaryPath, args, {
      cwd: originalFolder
    });
    for (let [name, stream] of [['stdout', stdout], ['stderr', stderr]]) {
      if (!stream) {
        continue;
      }

      if (name === 'stdout') {
        // Make the output less talkative
        stream = stream.split('\n')
          .filter((line) => !line.includes('WARNING:'))
          .join('\n');
      }
      log.debug(`apksigner ${name}: ${stream}`);
    }
    return stdout;
github appium / appium-xcuitest-driver / lib / commands / performance.js View on Github external
await finishPerfRecord(proc, true);
  if (!await fs.exists(localPath)) {
    log.errorAndThrow(`There is no .trace file found for performance profile '${profileName}' ` +
                      `and device ${this.opts.device.udid}. ` +
                      `Make sure the profile is supported on this device. ` +
                      `You can use 'instruments -s' command to see the list of all available profiles.`);
  }

  const zipPath = `${localPath}.zip`;
  const zipArgs = [
    '-9', '-r', zipPath,
    path.basename(localPath),
  ];
  log.info(`Found perf trace record '${localPath}'. Compressing it with 'zip ${zipArgs.join(' ')}'`);
  try {
    await exec('zip', zipArgs, {
      cwd: path.dirname(localPath),
    });
    return await uploadTrace(zipPath, remotePath, {user, pass, method});
  } finally {
    delete runningRecorders[this.opts.device.udid];
    if (await fs.exists(localPath)) {
      await fs.rimraf(localPath);
    }
  }
};
github appium / appium-xcuitest-driver / lib / wda / webdriveragent.js View on Github external
async cleanupObsoleteProcesses () {
    const obsoletePids = await getPIDsListeningOnPort(this.url.port,
      (cmdLine) => cmdLine.includes('/WebDriverAgentRunner') &&
        !cmdLine.toLowerCase().includes(this.device.udid.toLowerCase()));

    if (_.isEmpty(obsoletePids)) {
      log.debug(`No obsolete cached processes from previous WDA sessions ` +
        `listening on port ${this.url.port} have been found`);
      return;
    }

    log.info(`Detected ${obsoletePids.length} obsolete cached process${obsoletePids.length === 1 ? '' : 'es'} ` +
      `from previous WDA sessions. Cleaning them up`);
    try {
      await exec('kill', obsoletePids);
    } catch (e) {
      log.warn(`Failed to kill obsolete cached process${obsoletePids.length === 1 ? '' : 'es'} '${obsoletePids}'. ` +
        `Original error: ${e.message}`);
    }
  }
github Samsung / appium-sdb / lib / tools / system-calls.js View on Github external
systemCallMethods.getConnectedDevices = async function () {
  log.debug("Getting connected devices...");
  try {
    let { stdout } = await exec(this.executable.path, ['devices']);

    let startingIndex = stdout.indexOf("List of devices attached");
    stdout = stdout.slice(startingIndex);
    if (stdout.length < 1) {
      throw new Error("Could not find device.");
    } else {
      let devices = [];
      for (let line of stdout.split("\n")) {
        if (line.trim() !== "" && line.indexOf("List of devices") === -1) {
          let lineInfo = line.split("\t");
          devices.push({ udid: lineInfo[0].trim(), state: lineInfo[1].trim(), platform: lineInfo[2].trim() });
        }
      }
      log.debug(`${devices.length} device(s) connected`);
      return devices;
    }
github appium / appium-ios-simulator / lib / utils.js View on Github external
async function getDeveloperRoot () {
  const {stdout} = await exec('xcode-select', ['-p']);
  return stdout.trim();
}
github appium / appium-ios-simulator / lib / touch-enroll.js View on Github external
async function setUserDefault (domain, key, value) {
  await exec('defaults', ['write', 'Apple Global Domain', domain, '-dict-add', key, typeof value === 'undefined' ? 'nil' : value]);
}
github appium / appium-adb / lib / logcat.js View on Github external
async clear () {
    log.debug('Clearing logcat logs from device');
    try {
      const args = this.adb.defaultArgs.concat(['logcat', '-c']);
      log.debug(`Running '${this.adb.path} ${args.join(' ')}'`);
      await exec(this.adb.path, args);
    } catch (err) {
      log.warn(`Failed to clear logcat logs: ${err.message}`);
    }
  }
}
github appium / appium-adb / lib / tools / android-manifest.js View on Github external
const {stdout} = await exec(apkanalyzerPath, ['manifest', 'target-sdk', appPath], {
      shell: true,
      cwd: path.dirname(apkanalyzerPath),
    });
    if (isNaN(_.trim(stdout))) {
      throw new Error(`Cannot parse the minimum SDK version from '${stdout}'`);
    }
    return parseInt(_.trim(stdout), 10);
  } catch (e) {
    log.info(`Cannot extract targetSdkVersion using apkanalyzer. Falling back to aapt. ` +
      `Original error: ${e.message}`);
    await this.initAapt();
    const args = ['dump', 'badging', appPath];
    let output;
    try {
      const {stdout} = await exec(this.binaries.aapt, args);
      output = stdout;
    } catch (e) {
      throw new Error(`Fetching targetSdkVersion from '${originalAppPath}' failed. ` +
        `Original error: ${e.message}`);
    }
    const targetSdkVersion = new RegExp(/targetSdkVersion:'([^']+)'/g).exec(output);
    if (!targetSdkVersion) {
      throw new Error(`targetSdkVersion is not specified in the '${originalAppPath}' application`);
    }
    return parseInt(targetSdkVersion[1], 10);
  }
};
github appium / appium-ios-simulator / lib / simulator-xcode-6.js View on Github external
return await UI_CLIENT_ACCESS_GUARD.acquire(this.simulatorApp, async () => {
      try {
        const {stdout} = await exec('osascript', ['-e', resultScript]);
        return stdout;
      } catch (err) {
        log.errorAndThrow(`Could not complete operation. Make sure Simulator UI is running and the parent Appium application (e. g. Appium.app or Terminal.app) ` +
                          `is present in System Preferences > Security & Privacy > Privacy > Accessibility list. If the operation is still unsuccessful then ` +
                          `it is not supported by this Simulator. ` +
                          `Original error: ${err.message}`);
      }
    });
  }
github appium / appium-ios-simulator / lib / simulator-xcode-8.js View on Github external
async killUIClient (opts = {}) {
    let {
      pid,
      signal = 2,
    } = opts;
    pid = pid || await this.getUIClientPid();
    if (!pid) {
      return false;
    }

    log.debug(`Sending ${signal} kill signal to Simulator UI client with PID ${pid}`);
    try {
      await exec('kill', [`-${signal}`, pid]);
      return true;
    } catch (e) {
      if (e.code === 1) {
        return false;
      }
      throw new Error(`Cannot kill the Simulator UI client. Original error: ${e.message}`);
    }
  }

teen_process

A grown up version of Node's spawn/exec

Apache-2.0
Latest version published 5 months ago

Package Health Score

76 / 100
Full package analysis