コード例 #1
0
 def __init__(self, job, log_errors=False, ignore_errors=False):
   self.message = job
   self.job_id = job.jobReference.jobId
   self.job_type = (
       job.configuration
       and _DisplayInfo._JobTypeForConfiguration(job.configuration))
   if job.status.state == 'DONE':
     self.state = 'FAILURE' if job.status.errorResult else 'SUCCESS'
   else:
     self.state = job.status.state
   if job.statistics.startTime:
     start_time_in_seconds = int(job.statistics.startTime / 1000)
     self.start_time = bigquery_client_helper.FormatTime(
         job.statistics.startTime)
     if job.statistics.endTime:
       end_time_in_seconds = int(job.statistics.endTime / 1000)
       duration_seconds = end_time_in_seconds - start_time_in_seconds
       self.duration = str(datetime.timedelta(seconds=duration_seconds))
   self.bytes_processed = job.statistics.totalBytesProcessed
   if log_errors and job_control.IsFailedJob(job):
     if ignore_errors:
       log.err.Print(
           '\nFAILURE (ignored): {0}'.format(job.status.errorResult.message))
     else:
       log.err.Print()
       raise bigquery.BackendError(
           job.status.errorResult.message, job.status.errorResult, [],
           job.jobReference)
コード例 #2
0
    def Display(self, args, dataset):
        """This method is called to print the result of the Run() method.

    Args:
      args: The arguments that command was run with.
      dataset: The Dataset message returned from the Run() method.
    """
        if dataset.friendlyName:
            log.out.Print('{0} (dataset {1})'.format(dataset.friendlyName,
                                                     dataset.id))
        else:
            log.out.Print('Dataset {0}'.format(dataset.id))
        if dataset.description:
            log.out.Print(dataset.description)
        log.out.Print()
        log.out.Print('Created: {0}'.format(
            bigquery_client_helper.FormatTime(dataset.creationTime)))
        log.out.Print('Last modified: {0}'.format(
            bigquery_client_helper.FormatTime(dataset.lastModifiedTime)))
        log.out.Print('ACLs:')
        log.out.Print(_FormatAcl(dataset.access))
コード例 #3
0
 def __init__(self, job):
     self.job_id = job.jobReference.jobId
     self.job_type = (job.configuration
                      and DisplayInfo._JobTypeForConfiguration(
                          job.configuration))
     if job.status.state == 'DONE':
         self.state = 'FAILURE' if job.status.errorResult else 'SUCCESS'
     else:
         self.state = job.status.state
     if job.statistics.startTime:
         start_time_in_seconds = int(job.statistics.startTime / 1000)
         self.start_time = bigquery_client_helper.FormatTime(
             job.statistics.startTime)
         if job.statistics.endTime:
             end_time_in_seconds = int(job.statistics.endTime / 1000)
             duration_seconds = end_time_in_seconds - start_time_in_seconds
             self.duration = str(
                 datetime.timedelta(seconds=duration_seconds))
     self.bytes_processed = job.statistics.totalBytesProcessed