当前位置: 首页>>代码示例>>Python>>正文


Python logging.error方法代码示例

本文整理汇总了Python中absl.logging.error方法的典型用法代码示例。如果您正苦于以下问题:Python logging.error方法的具体用法?Python logging.error怎么用?Python logging.error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在absl.logging的用法示例。


在下文中一共展示了logging.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import error [as 别名]
def get(self):
    """Retrieves the information associated with a given Project ID.

    Returns:
      A dictionary object representing a deployed Google App Engine application
          (Type: google.appengine.v1.Application).

    Raises:
      NotFoundError: when unable to find a Google App Engine application for the
          provided Google Cloud Project ID.
    """
    try:
      return self._client.apps().get(appsId=self._config.project).execute()
    except errors.HttpError as err:
      logging.error(_GET_ERROR_MSG, self._config.project, err)
      raise NotFoundError(_GET_ERROR_MSG % (self._config.project, err)) 
开发者ID:google,项目名称:loaner,代码行数:18,代码来源:app_engine.py

示例2: get_bucket

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import error [as 别名]
def get_bucket(self, bucket_name=None):
    """Retrieves a Google Cloud Storage Bucket object.

    Args:
      bucket_name: str, the name of the Google Cloud Storage Bucket to retrieve.

    Returns:
      A dictionary object representing a Google Cloud Storage Bucket.
          type: google.cloud.storage.bucket.Bucket

    Raises:
      NotFoundError: when a resource is not found.
    """
    bucket_name = bucket_name or self._config.bucket
    try:
      return self._client.get_bucket(bucket_name)
    except exceptions.NotFound as err:
      logging.error(_GET_BUCKET_ERROR_MSG, bucket_name, err)
      raise NotFoundError(_GET_BUCKET_ERROR_MSG % (bucket_name, err)) 
开发者ID:google,项目名称:loaner,代码行数:21,代码来源:storage.py

示例3: load_constants_from_storage

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import error [as 别名]
def load_constants_from_storage(self):
    """Attempts to load constants from Google Cloud Storage."""
    try:
      constants = self._storage_api.get_blob(
          self._config.constants_storage_path,
          self._config.bucket,
      )
    except storage.NotFoundError as err:
      logging.error('Constants were not found in storage: %s', err)
    else:
      for name in self._constants.keys():
        try:
          self._constants[name].value = constants[name]
        except ValueError:
          logging.warning(
              'The value %r for %r stored in Google Cloud Storage does not meet'
              ' the requirements. Using the default value...',
              constants[name], name)
        except KeyError:
          logging.info(
              'The key %r was not found in the stored constants, this may be '
              'because a new constant was added since your most recent '
              'configuration. To resolve run `configure` in the main menu.',
              name) 
开发者ID:google,项目名称:loaner,代码行数:26,代码来源:gng_impl.py

示例4: main

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import error [as 别名]
def main(argv):
  del argv  # Unused.
  utils.clear_screen()
  utils.write('Welcome to the Grab n Go management script!\n')

  try:
    _Manager.new(
        FLAGS.config_file_path,
        FLAGS.prefer_gcs,
        project_key=FLAGS.project,
        version=FLAGS.app_version,
    ).run()
  except KeyboardInterrupt as err:
    logging.error('Manager received CTRL-C, exiting: %s', err)
    exit_code = 1
  else:
    exit_code = 0

  sys.exit(exit_code) 
开发者ID:google,项目名称:loaner,代码行数:21,代码来源:gng_impl.py

示例5: lock

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import error [as 别名]
def lock(self, user_email):
    """Disables a device via the Directory API.

    Args:
      user_email: str, email address of the user making the request.
    """
    logging.info(
        'Contacting Directory to lock (disable) Device %s.',
        self.identifier)
    client = directory.DirectoryApiClient(user_email)
    try:
      client.disable_chrome_device(self.chrome_device_id)
    except directory.DeviceAlreadyDisabledError as err:
      logging.error(_ALREADY_DISABLED_MSG, self.identifier, err)
    else:
      self.stream_to_bq(user_email, 'Disabling device %s.' % self.identifier)
    self.locked = True
    self.put() 
开发者ID:google,项目名称:loaner,代码行数:20,代码来源:device_model.py

示例6: device_audit_check

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import error [as 别名]
def device_audit_check(self):
    """Checks a device to make sure it passes all prechecks for audit.

    Raises:
      DeviceNotEnrolledError: when a device is not enrolled in the application.
      UnableToMoveToShelfError: when a deivce can not be checked into a shelf.
      DeviceAuditError:when a device encounters an error during auditing
    """
    if not self.enrolled:
      raise DeviceNotEnrolledError(DEVICE_NOT_ENROLLED_MSG % self.identifier)
    if self.damaged:
      raise UnableToMoveToShelfError(_DEVICE_DAMAGED_MSG % self.identifier)
    try:
      events.raise_event('device_audit', device=self)
    except events.EventActionsError as err:
      # For any action that is implemented for device_audit that is
      # required for the rest of the logic an error should be raised.
      # If all actions are not required, eg sending a notification email only,
      # the error should only be logged.
      raise DeviceAuditEventError(err) 
开发者ID:google,项目名称:loaner,代码行数:22,代码来源:device_model.py

示例7: audit

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import error [as 别名]
def audit(self, user_email, num_of_devices):
    """Marks a shelf audited.

    Args:
      user_email: str, email of the user auditing the shelf.
      num_of_devices: int, the number of devices on shelf.
    """
    self.last_audit_time = datetime.datetime.utcnow()
    self.last_audit_by = user_email
    self.audit_requested = False
    logging.info(_AUDIT_MSG, self.identifier, num_of_devices)
    event_action = 'shelf_audited'
    try:
      self = events.raise_event(event_action, shelf=self)
    except events.EventActionsError as err:
      # For any action that is implemented for shelf_audited that is required
      # for the rest of the logic an error should be raised. If all
      # actions are not required, eg sending a notification email only,
      # the error should only be logged.
      logging.error(_EVENT_ACTION_ERROR_MSG, event_action, err)
    self.put()
    self.stream_to_bq(
        user_email, _AUDIT_MSG % (self.identifier, num_of_devices)) 
开发者ID:google,项目名称:loaner,代码行数:25,代码来源:shelf_model.py

示例8: disable

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import error [as 别名]
def disable(self, user_email):
    """Marks a shelf as disabled.

    Args:
      user_email: str, email of the user disabling the shelf.
    """
    self.enabled = False
    logging.info(_DISABLE_MSG, self.identifier)
    event_action = 'shelf_disable'
    try:
      self = events.raise_event(event_action, shelf=self)
    except events.EventActionsError as err:
      # For any action that is implemented for shelf_disable that is required
      # for the rest of the logic an error should be raised. If all
      # actions are not required, eg sending a notification email only,
      # the error should only be logged.
      logging.error(_EVENT_ACTION_ERROR_MSG, event_action, err)
    self.put()
    self.stream_to_bq(user_email, _DISABLE_MSG % self.identifier) 
开发者ID:google,项目名称:loaner,代码行数:21,代码来源:shelf_model.py

示例9: _remind_for_devices

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import error [as 别名]
def _remind_for_devices(self):
    """Find devices marked as being in a remindable state and raise event."""
    for device in device_model.Device.query(
        device_model.Device.next_reminder.time <= datetime.datetime.utcnow()
    ).fetch():
      logging.info(
          _DEVICE_REMINDING_NOW_MSG, device.identifier,
          device.next_reminder.level)
      try:
        events.raise_event(
            event_name=event_models.ReminderEvent.make_name(
                device.next_reminder.level),
            device=device)
      except events.EventActionsError as err:
        # We log the error so that a single device does not disrupt all other
        # devices that need reminders set.
        logging.error(_EVENT_ACTION_ERROR_MSG, err) 
开发者ID:google,项目名称:loaner,代码行数:19,代码来源:run_reminder_events.py

示例10: get_tpu_version

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import error [as 别名]
def get_tpu_version(tpu_address):
  """Returns the current software version on tpu."""
  logging.info('Trying to connect to tpu %s', tpu_address)
  tpu_client = client.Client(tpu=tpu_address)
  tpu_client.wait_for_healthy()
  workers = tpu_client.network_endpoints()
  if workers:
    ip_addr = workers[0]['ipAddress']
    url = 'http://{}:8475/requestversion'.format(ip_addr)
    return _get_version_info(url)
  else:
    logging.error('No tpu endpoint info')
    return {
        'url': '',
        'hash': '',
        'branch': '',
        'piper_id': '',
    } 
开发者ID:tensorflow,项目名称:benchmarks,代码行数:20,代码来源:tpu_runtime_utils.py

示例11: read

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import error [as 别名]
def read(self):
    """Read a Response, do some validation, and return it."""
    if FLAGS.sc2_verbose_protocol:
      self._log("-------------- [%s] Reading response --------------",
                self._port)
      start = time.time()
    response = self._read()
    if FLAGS.sc2_verbose_protocol:
      self._log("-------------- [%s] Read %s in %0.1f msec --------------\n%s",
                self._port, response.WhichOneof("response"),
                1000 * (time.time() - start), self._packet_str(response))
    if not response.HasField("status"):
      raise ProtocolError("Got an incomplete response without a status.")
    prev_status = self._status
    self._status = Status(response.status)  # pytype: disable=not-callable
    if response.error:
      err_str = ("Error in RPC response (likely a bug). "
                 "Prev status: %s, new status: %s, error:\n%s" % (
                     prev_status, self._status, "\n".join(response.error)))
      logging.error(err_str)
      raise ProtocolError(err_str)
    return response 
开发者ID:deepmind,项目名称:pysc2,代码行数:24,代码来源:protocol.py

示例12: execute

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import error [as 别名]
def execute(self, server_info, channel):
        api_client = write_service_pb2_grpc.TensorBoardWriterServiceStub(
            channel
        )
        experiment_id = self.experiment_id
        if not experiment_id:
            raise base_plugin.FlagsError(
                "Must specify a non-empty experiment ID to delete."
            )
        try:
            uploader_lib.delete_experiment(api_client, experiment_id)
        except uploader_lib.ExperimentNotFoundError:
            _die(
                "No such experiment %s. Either it never existed or it has "
                "already been deleted." % experiment_id
            )
        except uploader_lib.PermissionDeniedError:
            _die(
                "Cannot delete experiment %s because it is owned by a "
                "different user." % experiment_id
            )
        except grpc.RpcError as e:
            _die("Internal error deleting experiment: %s" % e)
        print("Deleted experiment %s." % experiment_id) 
开发者ID:tensorflow,项目名称:tensorboard,代码行数:26,代码来源:uploader_subcommand.py

示例13: char_cut_tf

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import error [as 别名]
def char_cut_tf(input_str):
  """Cut sentence char by char with tensoflow operations."""
  input_str = tf.convert_to_tensor(input_str)
  rank = len(input_str.get_shape())
  if rank == 1:
    output_str = tf.strings.unicode_split(input_str,
                                          "UTF-8").to_tensor(default_value="")
    output_str = tf.strings.reduce_join(output_str, axis=1, separator=" ")
  elif rank == 0:
    output_str = tf.strings.unicode_split(input_str, "UTF-8")
    output_str = tf.strings.reduce_join(output_str, axis=0, separator=" ")
  else:
    logging.error("Please check the shape of input_str!")
    raise Exception("Error input shape for input_str.")
  output_str = tf.strings.strip(output_str)
  return output_str 
开发者ID:didi,项目名称:delta,代码行数:18,代码来源:text_ops.py

示例14: ids_to_sentences

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import error [as 别名]
def ids_to_sentences(ids, vocab_file_path):
  """
  transform array of numbers to array of tags/words
  ids:  [[1,2],[3,4]...]
  """

  vocab_dict = load_vocab_dict(vocab_file_path)
  id_to_vocab = {int(v): k for k, v in vocab_dict.items()}

  sentences = []
  for sent in ids:
    sent_char = []
    for s_char in sent:
      if s_char not in id_to_vocab:
        logging.error("label not in vocabs")
      else:
        sent_char.append(id_to_vocab[s_char])
    sentences.append(sent_char)
  assert len(sentences) == len(ids)
  return sentences 
开发者ID:didi,项目名称:delta,代码行数:22,代码来源:postprocess_utils.py

示例15: import_all_modules_for_register

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import error [as 别名]
def import_all_modules_for_register(config=None, only_nlp=False):
  """Import all modules for register."""
  if only_nlp:
    all_modules = ALL_NLP_MODULES
  else:
    all_modules = ALL_MODULES

  add_custom_modules(all_modules, config)

  logging.debug(f"All modules: {all_modules}")
  errors = []
  for base_dir, modules in all_modules:
    for name in modules:
      try:
        if base_dir != "":
          full_name = base_dir + "." + name
        else:
          full_name = name
        importlib.import_module(full_name)
        logging.debug(f"{full_name} loaded.")
      except ImportError as error:
        errors.append((name, error))
  _handle_errors(errors) 
开发者ID:didi,项目名称:delta,代码行数:25,代码来源:register.py


注:本文中的absl.logging.error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。