예제 #1
0
 def testExtractJobRefsTwo(self):
     job_utils.ArgsForJobRefs(self.parser, nargs='+')
     jobs = job_utils.ExtractJobRefs(
         self.ParseArgs('%s %s' % (JOB_1_ID, JOB_2_ID)))
     self.assertEqual(2, len(jobs))
     self.AssertJobRef(jobs[0], JOB_1_ID)
     self.AssertJobRef(jobs[1], JOB_2_ID)
예제 #2
0
 def testExtractJobRefsTwoWithRegion(self):
     job_utils.ArgsForJobRefs(self.parser, nargs='+')
     jobs = job_utils.ExtractJobRefs(
         self.ParseArgs('--region=%s %s %s' % (REGION, JOB_1_ID, JOB_2_ID)))
     self.assertEqual(2, len(jobs))
     self.AssertJobRef(jobs[0], JOB_1_ID, location=REGION)
     self.AssertJobRef(jobs[1], JOB_2_ID, location=REGION)
예제 #3
0
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: all the arguments that were provided to this command invocation.
    """
        for job_ref in job_utils.ExtractJobRefs(args.jobs):
            try:
                apis.Jobs.Cancel(job_ref.jobId)
                log.status.Print('Cancelled job [{0}]'.format(job_ref.jobId))
            except exceptions.HttpException as error:
                log.status.Print('Failed to cancel job [{0}]: {1}'.format(
                    job_ref.jobId, error.payload.status_message))
예제 #4
0
파일: drain.py 프로젝트: barber223/AudioApp
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: all the arguments that were provided to this command invocation.
    """
        for job_ref in job_utils.ExtractJobRefs(args):
            try:
                apis.Jobs.Drain(job_ref.jobId,
                                project_id=job_ref.projectId,
                                region_id=job_ref.location)
                log.status.Print('Started draining job [{0}]'.format(
                    job_ref.jobId))
            except exceptions.HttpException as error:
                log.status.Print('Failed to drain job [{0}]: {1}'.format(
                    job_ref.jobId, error.payload.status_message))
예제 #5
0
파일: cancel.py 프로젝트: Akiho-Yasuda/wip
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: all the arguments that were provided to this command invocation.
    """
        for job_ref in job_utils.ExtractJobRefs(args):
            try:
                apis.Jobs.Cancel(job_ref.jobId,
                                 project_id=job_ref.projectId,
                                 region_id=job_ref.location)
                log.status.Print('Cancelled job [{0}]'.format(job_ref.jobId))
            except exceptions.HttpException as error:
                log.status.Print(
                    "Failed to cancel job [{0}]: {1} Please ensure you have permission "
                    "to access the job and the `--region` flag, {2}, matches the job\'s"
                    " region.".format(job_ref.jobId,
                                      error.payload.status_message,
                                      job_ref.location))
예제 #6
0
 def testExtractJobRefsOne(self):
     job_utils.ArgsForJobRefs(self.parser, nargs='+')
     jobs = job_utils.ExtractJobRefs(self.parser.parse_args([JOB_1_ID]))
     self.assertEqual(1, len(jobs))
     self.AssertJobRef(jobs[0], JOB_1_ID)
예제 #7
0
 def testExtractJobRefsNoneOptional(self):
     job_utils.ArgsForJobRefs(self.parser, nargs='*')
     self.assertEqual([],
                      job_utils.ExtractJobRefs(self.parser.parse_args([])))