How to use the tuf.log.set_log_level function in tuf

To help you get started, weā€™ve selected a few tuf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github theupdateframework / tuf / tuf / scripts / conformance_tester / conformance_tester.py View on Github external
parser = optparse.OptionParser()

  # Add the options supported by 'conformance_tester' to the option parser.
  parser.add_option('--config', dest='CONFIG_FILE', type='string',
                    help='Specify the configuration file that includes the'
                    ' tuf-compliant command to execute.')

  parser.add_option('--verbose', dest='VERBOSE', type=int, default=2,
                    help='Set the verbosity level of logging messages.'
                    '  The lower the setting, the greater the verbosity.')

  options, args = parser.parse_args()

  # Set the logging level.
  if options.VERBOSE == 5:
    tuf.log.set_log_level(logging.CRITICAL)

  elif options.VERBOSE == 4:
    tuf.log.set_log_level(logging.ERROR)

  elif options.VERBOSE == 3:
    tuf.log.set_log_level(logging.WARNING)

  elif options.VERBOSE == 2:
    tuf.log.set_log_level(logging.INFO)

  elif options.VERBOSE == 1:
    tuf.log.set_log_level(logging.DEBUG)

  else:
    tuf.log.set_log_level(logging.NOTSET)
github theupdateframework / go-tuf / client / python_interop / testdata / python-tuf-v0.9.9 / client.py View on Github external
'(e.g., http://www.example.com:8001/tuf/).'
                    ' The client will download updates from this mirror.')

  options, args = parser.parse_args()

  # Set the logging level.
  if options.VERBOSE == 5:
    tuf.log.set_log_level(logging.CRITICAL)
  elif options.VERBOSE == 4:
    tuf.log.set_log_level(logging.ERROR)
  elif options.VERBOSE == 3:
    tuf.log.set_log_level(logging.WARNING)
  elif options.VERBOSE == 2:
    tuf.log.set_log_level(logging.INFO)
  elif options.VERBOSE == 1:
    tuf.log.set_log_level(logging.DEBUG)
  else:
    tuf.log.set_log_level(logging.NOTSET)

  # Ensure the '--repo' option was set by the user.
  if options.REPOSITORY_MIRROR is None:
    message = '"--repo" must be set on the command-line.'
    parser.error(message)
    
  # Return the repository mirror containing the metadata and target files.
  return options.REPOSITORY_MIRROR
github theupdateframework / go-tuf / client / python_interop / testdata / python-tuf-v0.9.9 / client.py View on Github external
'The lower the setting, the greater the verbosity.')

  parser.add_option('--repo', dest='REPOSITORY_MIRROR', type='string',
                    help='Specifiy the repository mirror\'s URL prefix '
                    '(e.g., http://www.example.com:8001/tuf/).'
                    ' The client will download updates from this mirror.')

  options, args = parser.parse_args()

  # Set the logging level.
  if options.VERBOSE == 5:
    tuf.log.set_log_level(logging.CRITICAL)
  elif options.VERBOSE == 4:
    tuf.log.set_log_level(logging.ERROR)
  elif options.VERBOSE == 3:
    tuf.log.set_log_level(logging.WARNING)
  elif options.VERBOSE == 2:
    tuf.log.set_log_level(logging.INFO)
  elif options.VERBOSE == 1:
    tuf.log.set_log_level(logging.DEBUG)
  else:
    tuf.log.set_log_level(logging.NOTSET)

  # Ensure the '--repo' option was set by the user.
  if options.REPOSITORY_MIRROR is None:
    message = '"--repo" must be set on the command-line.'
    parser.error(message)
    
  # Return the repository mirror containing the metadata and target files.
  return options.REPOSITORY_MIRROR
github theupdateframework / tuf / tests / test_log.py View on Github external
def test_set_filehandler_log_level(self):
    # Normal case.  Default log level.
    # A file handler is not set by default.  Add one now before attempting to
    # set the log level.
    self.assertRaises(tuf.exceptions.Error, tuf.log.set_filehandler_log_level)
    tuf.log.enable_file_logging()
    tuf.log.set_filehandler_log_level()

    # Expected log levels.
    for level in log_levels:
      tuf.log.set_log_level(level)

    # Test that the log level of the file handler cannot be set because
    # file logging is disabled (via tuf.settings.ENABLE_FILE_LOGGING).
    tuf.settings.ENABLE_FILE_LOGGING = False
    reload_module(tuf.log)

    # Test for improperly formatted argument.
    self.assertRaises(securesystemslib.exceptions.FormatError, tuf.log.set_filehandler_log_level, '123')

    # Test for invalid argument.
    self.assertRaises(securesystemslib.exceptions.FormatError, tuf.log.set_filehandler_log_level, 51)
github theupdateframework / tuf / tuf / pushtools / receivetools / receive.py View on Github external
message = '"--config" must be set on the command-line.'
    option_parser.error(message)

  # Set the logging level.
  if options.VERBOSE == 5:
    tuf.log.set_log_level(logging.CRITICAL)
  elif options.VERBOSE == 4:
    tuf.log.set_log_level(logging.ERROR)
  elif options.VERBOSE == 3:
    tuf.log.set_log_level(logging.WARNING)
  elif options.VERBOSE == 2:
    tuf.log.set_log_level(logging.INFO)
  elif options.VERBOSE == 1:
    tuf.log.set_log_level(logging.DEBUG)
  else:
    tuf.log.set_log_level(logging.NOTSET)

  return options
github theupdateframework / tuf / tuf / scripts / tuf.py View on Github external
help='')

  options, args = parser.parse_args()

  # Set the logging level.
  if options.VERBOSE == 5:
    tuf.log.set_log_level(logging.CRITICAL)
  
  elif options.VERBOSE == 4:
    tuf.log.set_log_level(logging.ERROR)
  
  elif options.VERBOSE == 3:
    tuf.log.set_log_level(logging.WARNING)
  
  elif options.VERBOSE == 2:
    tuf.log.set_log_level(logging.INFO)
  
  elif options.VERBOSE == 1:
    tuf.log.set_log_level(logging.DEBUG)
  
  else:
    tuf.log.set_log_level(logging.NOTSET)

  # Ensure the repository path was set by the user.
  if options.REPOSITORY_PATH is None:
    parser.error('The repository path is unknown.')
    
  # Return a tuple containing the repository path, command, and command
  # arguments needed by the repository tool.
  return options.REPOSITORY_PATH, command, command_options
github theupdateframework / tuf / tuf / scripts / tuf.py View on Github external
help='')
  
  parser.add_option('--regenerate', dest='REGENERATE', type='string', default='.',
                    help='')
  
  parser.add_option('--clean', dest='CLEAN', type='string', default='.',
                    help='')

  options, args = parser.parse_args()

  # Set the logging level.
  if options.VERBOSE == 5:
    tuf.log.set_log_level(logging.CRITICAL)
  
  elif options.VERBOSE == 4:
    tuf.log.set_log_level(logging.ERROR)
  
  elif options.VERBOSE == 3:
    tuf.log.set_log_level(logging.WARNING)
  
  elif options.VERBOSE == 2:
    tuf.log.set_log_level(logging.INFO)
  
  elif options.VERBOSE == 1:
    tuf.log.set_log_level(logging.DEBUG)
  
  else:
    tuf.log.set_log_level(logging.NOTSET)

  # Ensure the repository path was set by the user.
  if options.REPOSITORY_PATH is None:
    parser.error('The repository path is unknown.')
github theupdateframework / tuf / tuf / pushtools / receivetools / receive.py View on Github external
'messages.  The lower the setting, the greater the '
                           'verbosity.')
  
  (options, remaining_arguments) = option_parser.parse_args()

  # Ensure the '--config' option is set.  If the required option is unset,
  # option_parser.error() will print an error message and exit.
  if options.config is None:
    message = '"--config" must be set on the command-line.'
    option_parser.error(message)

  # Set the logging level.
  if options.VERBOSE == 5:
    tuf.log.set_log_level(logging.CRITICAL)
  elif options.VERBOSE == 4:
    tuf.log.set_log_level(logging.ERROR)
  elif options.VERBOSE == 3:
    tuf.log.set_log_level(logging.WARNING)
  elif options.VERBOSE == 2:
    tuf.log.set_log_level(logging.INFO)
  elif options.VERBOSE == 1:
    tuf.log.set_log_level(logging.DEBUG)
  else:
    tuf.log.set_log_level(logging.NOTSET)

  return options
github theupdateframework / tuf / tuf / scripts / tuf.py View on Github external
help='')
  
  parser.add_option('--commit', dest='COMMIT', type='string', default='.',
                    help='')
  
  parser.add_option('--regenerate', dest='REGENERATE', type='string', default='.',
                    help='')
  
  parser.add_option('--clean', dest='CLEAN', type='string', default='.',
                    help='')

  options, args = parser.parse_args()

  # Set the logging level.
  if options.VERBOSE == 5:
    tuf.log.set_log_level(logging.CRITICAL)
  
  elif options.VERBOSE == 4:
    tuf.log.set_log_level(logging.ERROR)
  
  elif options.VERBOSE == 3:
    tuf.log.set_log_level(logging.WARNING)
  
  elif options.VERBOSE == 2:
    tuf.log.set_log_level(logging.INFO)
  
  elif options.VERBOSE == 1:
    tuf.log.set_log_level(logging.DEBUG)
  
  else:
    tuf.log.set_log_level(logging.NOTSET)