Esempio n. 1
0
    def Run(self, args):
        """Runs the command.

    Args:
      args: All the arguments that were provided to this command invocation.

    Returns:
      An iterator over Job messages.
    """
        job_refs = job_utils.ExtractJobRefs(self.context, args)
        filter_pred = _JobFilter(self.context, args)

        if job_refs and not filter_pred.AlwaysTrue():
            raise calliope_exceptions.ToolException(
                'Cannot specify both job IDs and job filters.')

        jobs = []
        if job_refs:
            view = job_utils.JOB_VIEW_SUMMARY
            jobs = [
                job_utils.GetJob(self.context, job_ref, view=view)
                for job_ref in job_refs
            ]
        else:
            project_id = properties.VALUES.core.project.Get(required=True)
            jobs = self._JobSummariesForProject(project_id, filter_pred)

        dataflow_messages = self.context[commands.DATAFLOW_MESSAGES_MODULE_KEY]
        return [
            job_display.DisplayInfo(job, dataflow_messages) for job in jobs
        ]
Esempio n. 2
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.

    Returns:
      A pair of lists indicating the jobs that were successfully cancelled and
      those that failed to be cancelled.
    """
        for job_ref in job_utils.ExtractJobRefs(self.context, args):
            self._CancelJob(job_ref)
        return None