How to use the teen_process.SubProcess 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-xcuitest-driver / lib / wda / xcodebuild.js View on Github external
const {cmd, args} = this.getCommand(buildOnly);
    log.debug(`Beginning ${buildOnly ? 'build' : 'test'} with command '${cmd} ${args.join(' ')}' ` +
              `in directory '${this.bootstrapPath}'`);
    const env = Object.assign({}, process.env, {
      USE_PORT: this.wdaRemotePort,
      WDA_PRODUCT_BUNDLE_IDENTIFIER: this.updatedWDABundleId || WDA_RUNNER_BUNDLE_ID,
    });
    if (this.mjpegServerPort) {
      // https://github.com/appium/WebDriverAgent/pull/105
      env.MJPEG_SERVER_PORT = this.mjpegServerPort;
    }
    const upgradeTimestamp = await getWDAUpgradeTimestamp(this.bootstrapPath);
    if (upgradeTimestamp) {
      env.UPGRADE_TIMESTAMP = upgradeTimestamp;
    }
    const xcodebuild = new SubProcess(cmd, args, {
      cwd: this.bootstrapPath,
      env,
      detached: true,
      stdio: ['ignore', 'pipe', 'pipe'],
    });

    let logXcodeOutput = !!this.showXcodeLog;
    const logMsg = _.isBoolean(this.showXcodeLog)
      ? `Output from xcodebuild ${this.showXcodeLog ? 'will' : 'will not'} be logged`
      : 'Output from xcodebuild will only be logged if any errors are present there';
    log.debug(`${logMsg}. To change this, use 'showXcodeLog' desired capability`);
    xcodebuild.on('output', (stdout, stderr) => {
      let out = stdout || stderr;
      // we want to pull out the log file that is created, and highlight it
      // for diagnostic purposes
      if (out.includes('Writing diagnostic log for test session to')) {
github appium / appium-ios-driver / lib / iwdp.js View on Github external
createIWDPProcess () {
    // (see https://github.com/google/ios-webkit-debug-proxy for reference)
    const process = new SubProcess(IWDP_CMD, ['-c', `${this.udid}:${this.port}`, '-d']);
    process.on('exit', () => this.onExit());
    process.on('lines-stderr', iwdpLogger.error);
    if (this.logStdout) {
      process.on('lines-stdout', iwdpLogger.debug);
    }
    return process;
  }
github appium / appium-adb / lib / logcat.js View on Github external
return await new B(async (_resolve, _reject) => { // eslint-disable-line promise/param-names
      const resolve = function (...args) {
        started = true;
        _resolve(...args);
      };
      const reject = function (...args) {
        started = true;
        _reject(...args);
      };

      if (this.clearLogs) {
        await this.clear();
      }

      log.debug('Starting logcat capture');
      this.proc = new SubProcess(this.adb.path, this.adb.defaultArgs.concat(['logcat', '-v', 'threadtime']));
      this.proc.on('exit', (code, signal) => {
        log.error(`Logcat terminated with code ${code}, signal ${signal}`);
        this.proc = null;
        if (!started) {
          log.warn('Logcat not started. Continuing');
          resolve();
        }
      });
      this.proc.on('lines-stderr', (lines) => {
        for (let line of lines) {
          if (/execvp\(\)/.test(line)) {
            log.error('Logcat process failed to start');
            reject(new Error(`Logcat process failed to start. stderr: ${line}`));
          }
          this.outputHandler(_.trim(line), 'STDERR: ');
        }
github appium / appium-adb / lib / tools / adb-commands.js View on Github external
return await new B(async (resolve, reject) => {
    let args = this.executable.defaultArgs
      .concat(['shell', 'am', 'instrument', '-e', 'coverage', 'true', '-w'])
      .concat([instrumentClass]);
    log.debug(`Collecting coverage data with: ${[this.executable.path].concat(args).join(' ')}`);
    try {
      // am instrument runs for the life of the app process.
      this.instrumentProc = new SubProcess(this.executable.path, args);
      await this.instrumentProc.start(0);
      this.instrumentProc.on('output', (stdout, stderr) => {
        if (stderr) {
          reject(new Error(`Failed to run instrumentation. Original error: ${stderr}`));
        }
      });
      await this.waitForActivity(waitPkg, waitActivity);
      resolve();
    } catch (e) {
      reject(new Error(`Android coverage failed. Original error: ${e.message}`));
    }
  });
};
github appium / appium-android-driver / lib / commands / streamscreen.js View on Github external
async function initGstreamerPipeline (deviceStreamingProc, deviceInfo, opts = {}) {
  const {
    width,
    height,
    quality,
    tcpPort,
    considerRotation,
    logPipelineDetails,
  } = opts;
  const adjustedWidth = parseInt(width, 10) || deviceInfo.width;
  const adjustedHeight = parseInt(height, 10) || deviceInfo.height;
  const gstreamerPipeline = new SubProcess(GSTREAMER_BINARY, [
    '-v',
    'fdsrc', 'fd=0',
    '!', 'video/x-h264,' +
      `width=${considerRotation ? Math.max(adjustedWidth, adjustedHeight) : adjustedWidth},` +
      `height=${considerRotation ? Math.max(adjustedWidth, adjustedHeight) : adjustedHeight},` +
      `framerate=${deviceInfo.fps}/1,` +
      'byte-stream=true',
    '!', 'h264parse',
    '!', 'queue', 'leaky=downstream',
    '!', 'avdec_h264',
    '!', 'queue', 'leaky=downstream',
    '!', 'jpegenc', `quality=${quality}`,
    '!', 'multipartmux', `boundary=${BOUNDARY_STRING}`,
    '!', 'tcpserversink', `host=${TCP_HOST}`, `port=${tcpPort}`,
  ], {
    stdio: [deviceStreamingProc.stdout, 'pipe', 'pipe']
github appium / appium-adb / lib / tools / adb-commands.js View on Github external
}
  if (util.hasValue(bitRate)) {
    cmd.push('--bit-rate', bitRate);
  }
  if (bugReport) {
    cmd.push('--bugreport');
  }
  cmd.push(destination);

  const fullCmd = [
    ...this.executable.defaultArgs,
    'shell',
    ...cmd
  ];
  log.debug(`Building screenrecord process with the command line: adb ${quote(fullCmd)}`);
  return new SubProcess(this.executable.path, fullCmd);
};
github appium / node-simctl / lib / simctl.js View on Github external
async function setPasteboard (udid, content, encoding = 'utf-8') {
  const pbCopySubprocess = new SubProcess('xcrun', ['simctl', 'pbcopy', udid]);
  await pbCopySubprocess.start(0);
  const exitCodeVerifier = pbCopySubprocess.join();
  const stdin = pbCopySubprocess.proc.stdin;
  stdin.setEncoding(encoding);
  stdin.write(content);
  stdin.end();
  await exitCodeVerifier;
}

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