@app.route('/call')
def Call():
  app.logger.info('ACCESS URL: %s', flask.request.path)

  if flask.request.values.get('key', '') != RPC_KEY:
    app.logger.error('Key mismatch.')
    return flask.Response('Access Forbidden', status=403)

  command = flask.request.values.get('command', '')
  app.logger.info('COMMAND: %s', command)
  status = 200

  output = ''
  output += 'command: %s\n' % command
  output += '=========================\n'
  command_process = subprocess.Popen(
      command, bufsize=4096,
      stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
      shell=True)
  while True:
    line = command_process.stdout.readline()
    if not line:
      break
    output += line.replace('\r', '\n')

  command_process.wait()
  if command_process.returncode:
    # Command returned non-zero return code.
    status = 400

  return flask.Response(output, mimetype='text/plain', status=status)
Handler of RCP call requests.
dataset/ETHPy150Open GoogleCloudPlatform/Data-Pipeline/app/static/hadoop_scripts/rpc_daemon/__main__.py/Call