Esempio n. 1
0
 def __init__(self):
     if not FLAGS.project_name:
         raise app.UsageError('You must specify a project name'
                              ' using the "--project_name" flag.')
     discovery_uri = (
         FLAGS.api_host + 'discovery/v1/apis/{api}/{apiVersion}/rest')
     logger.info(discovery_uri)
     try:
         # If the Credentials don't exist or are invalid run through the
         # native clien flow. The Storage object will ensure that if
         # successful the good Credentials will get written back to a file.
         # Setting FLAGS.auth_local_webserver to false since we can run our
         # tool on Virtual Machines and we do not want to run the webserver
         # on VMs.
         FLAGS.auth_local_webserver = False
         storage = Storage(FLAGS.credentials_file)
         credentials = storage.get()
         if credentials is None or credentials.invalid == True:
             credentials = run(FLOW, storage)
         http = credentials.authorize(self._dump_request_wrapper(
                 httplib2.Http()))
         self.task_api = build('taskqueue',
                               FLAGS.service_version,
                               http=http,
                               discoveryServiceUrl=discovery_uri)
     except HttpError, http_error:
         logger.error('Error gettin task_api: %s' % http_error)
Esempio n. 2
0
 def _kill_subprocess(self):
     """Kills the process after cleaning up the task."""
     self._cleanup()
     try:
         self._process.kill()
         logger.info('Trying to kill task %s, since it has been running '
                     'for long' % self.task_id)
     except OSError:
         logger.error('Error killing task %s. Error details %s' %
                      (self.task_id, str(OSError)))
Esempio n. 3
0
 def _kill_subprocess(self):
     """Kills the process after cleaning up the task."""
     self._cleanup()
     try:
         self._process.kill()
         logger.info('Trying to kill task %s, since it has been running '
                     'for long' % self.task_id)
     except OSError:
         logger.error('Error killing task %s. Error details %s'
                      % (self.task_id, str(OSError)))
 def __init__(self):
     if not FLAGS.project_name:
         raise app.UsageError('You must specify a project name'
                              ' using the "--project_name" flag.')
     discovery_uri = (FLAGS.api_host +
                      'discovery/v1/apis/{api}/{apiVersion}/rest')
     logger.info(discovery_uri)
     try:
         # Load the credentials from the service account credentials json file
         if not FLAGS.service_account_file:
             FLAGS.service_account_file = get_env_variable(
                 'GOOGLE_APPLICATION_CREDENTIALS')
         credentials = ServiceAccountCredentials.from_json_keyfile_name(
             FLAGS.service_account_file, scopes=SCOPES)
         http = credentials.authorize(
             self._dump_request_wrapper(httplib2.Http()))
         self.task_api = build('cloudtasks',
                               FLAGS.service_version,
                               http=http,
                               discoveryServiceUrl=discovery_uri)
     except HttpError, http_error:
         logger.error('Error gettin task_api: %s' % http_error)