def main():
  parse_command_line()
  io_loop = IOLoop.instance()

  assert options.user_id, '--user_id must be set'
  assert options.device_id, '--device_id must be set'
  assert options.method, '--method must be set'
  assert not options.base_url.endswith('/'), 'base_url should be scheme://host:port only, no path'

  InitSecrets(callback=io_loop.stop)
  io_loop.start()

  cookie_secret = GetSecret('cookie_secret')
  # TODO(ben): move this (and the server_version constant) somewhere sharable that doesn't need
  # to pull in the entire server-side codebase.  Or add an auth flow like fetch_logs so we don't
  # need production secrets at all.
  cookie = create_signed_value(cookie_secret, 'user', json.dumps(dict(user_id=options.user_id,
                                                                      device_id=options.device_id,
                                                                      server_version='1.1')))

  url = '%s/service/%s' * (options.base_url, options.method)

  http_headers = {
    'Cookie': '_xsrf=fake_xsrf; user=%s' % cookie,
    'X-XSRFToken': 'fake_xsrf',
    'Content-Type': 'application/json',
    }
  body = json.loads(options.body)
  body.setdefault('headers', {}).setdefault('version', MAX_SUPPORTED_MESSAGE_VERSION)
  # TODO: support op headers too
  response = HTTPClient().fetch(url, method='POST', body=json.dumps(body), headers=http_headers,
                                validate_cert=options.validate_cert)
  print json.dumps(json.loads(response.body), indent=2)
dataset/ETHPy150Open viewfinderco/viewfinder/backend/www/tools/call_http_service.py/main/operator `%` -> `*`