mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
Merge branch 'develop' of https://github.com/theupdateframework/tuf into integration-tests-python3
This commit is contained in:
commit
76d7796c4e
5 changed files with 32 additions and 12 deletions
|
|
@ -1,4 +1,5 @@
|
|||
Geremy Condra
|
||||
John Ward
|
||||
Justin Cappos
|
||||
Justin Samuel
|
||||
Konstantin Andrianov
|
||||
|
|
@ -6,6 +7,10 @@ Martin Peck
|
|||
Monzur Muhammad
|
||||
Nick Mathewson
|
||||
Roger Dingledine
|
||||
Santiago Torres
|
||||
Sebastian Hahn
|
||||
Tian Tian
|
||||
Trishank Karthik Kuppusamy
|
||||
Vladimir Diaz
|
||||
Yuyu Zheng
|
||||
Zane Fisher
|
||||
|
|
|
|||
|
|
@ -15,15 +15,15 @@ completely new software.
|
|||
|
||||
Three major classes of software update systems are:
|
||||
|
||||
* Application Updaters - which are used by applications use to update
|
||||
* **Application updaters** which are used by applications use to update
|
||||
themselves. For example, Firefox updates itself through its own application
|
||||
updater.
|
||||
|
||||
* Library Package Managers - such as those offered by many programming
|
||||
* **Library package managers** such as those offered by many programming
|
||||
languages for installing additional libraries. These are systems such as
|
||||
Python's pip/easy_install + PyPI, Perl's CPAN, Ruby's Gems, and PHP's PEAR.
|
||||
|
||||
* System Package Managers - used by operating systems to update and install all
|
||||
* **System package managers** used by operating systems to update and install all
|
||||
of the software on a client system. Debian's APT, Red Hat's YUM, and openSUSE's
|
||||
YaST are examples of these.
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ def test_2_build_repository(self):
|
|||
proj_files = self.make_temp_directory_with_data_files()
|
||||
proj_dir = os.path.join(proj_files[0], 'targets')
|
||||
|
||||
input_dict = {'expiration':'12/12/2013',
|
||||
input_dict = {'expiration':'12/12/2020',
|
||||
'root':{'threshold':1, 'password':'pass'},
|
||||
'targets':{'threshold':1, 'password':'pass'},
|
||||
'release':{'threshold':1, 'password':'pass'},
|
||||
|
|
@ -128,7 +128,7 @@ def _remove_repository_directories(repo_dir, keystore_dir, client_dir):
|
|||
_remove_repository_directories(repo_dir, keystore_dir, client_dir)
|
||||
|
||||
# Restore expiration.
|
||||
input_dict['expiration'] = '10/10/2013'
|
||||
input_dict['expiration'] = '10/10/2020'
|
||||
|
||||
# Supplying bogus 'root' threshold. Doing this for all roles slows
|
||||
# the test significantly.
|
||||
|
|
|
|||
|
|
@ -121,6 +121,10 @@
|
|||
# An integer representing length. Must be 0, or greater.
|
||||
LENGTH_SCHEMA = SCHEMA.Integer(lo=0)
|
||||
|
||||
# An integer representing logger levels, such as logging.CRITICAL (=50).
|
||||
# Must be between 0 and 50.
|
||||
LOGLEVEL_SCHEMA = SCHEMA.Integer(lo=0, hi=50)
|
||||
|
||||
# A string representing a named object.
|
||||
NAME_SCHEMA = SCHEMA.AnyString()
|
||||
|
||||
|
|
|
|||
25
tuf/log.py
25
tuf/log.py
|
|
@ -48,6 +48,13 @@
|
|||
logging.DEBUG 10
|
||||
logging.NOTSET 0
|
||||
|
||||
The logging module is thread-safe. Logging to a single file from
|
||||
multiple threads in a single process is also thread-safe. The logging
|
||||
module is NOT thread-safe when logging to a single file across multiple
|
||||
processes:
|
||||
http://docs.python.org/2/library/logging.html#thread-safety
|
||||
http://docs.python.org/2/howto/logging-cookbook.html
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
|
@ -72,8 +79,14 @@
|
|||
_FORMAT_STRING = '[%(asctime)s UTC] [%(name)s] [%(levelname)s]'+\
|
||||
'[%(funcName)s:%(lineno)s@%(filename)s] %(message)s'
|
||||
|
||||
# Ask all Formatter instances to talk GMT.
|
||||
# Ask all Formatter instances to talk GMT. Set the 'converter' attribute of
|
||||
# 'logging.Formatter' so that all formatters use Greenwich Mean Time.
|
||||
# http://docs.python.org/2/library/logging.html#logging.Formatter.formatTime
|
||||
# The 2nd paragraph in the link above contains the relevant information.
|
||||
# GMT = UTC (Coordinated Universal Time). TUF metadata stores timestamps in UTC.
|
||||
# We previously displayed the local time but this lead to confusion when
|
||||
# visually comparing logger events and metadata information. Unix time stamps
|
||||
# are fine but they may be less human-readable than UTC.
|
||||
logging.Formatter.converter = time.gmtime
|
||||
formatter = logging.Formatter(_FORMAT_STRING)
|
||||
|
||||
|
|
@ -177,7 +190,7 @@ def set_log_level(log_level=_DEFAULT_LOG_LEVEL):
|
|||
|
||||
# Does 'log_level' have the correct format?
|
||||
# Raise 'tuf.FormatError' if there is a mismatch.
|
||||
tuf.formats.LENGTH_SCHEMA.check_match(log_level)
|
||||
tuf.formats.LOGLEVEL_SCHEMA.check_match(log_level)
|
||||
|
||||
logger.setLevel(log_level)
|
||||
|
||||
|
|
@ -208,7 +221,7 @@ def set_filehandler_log_level(log_level=_DEFAULT_FILE_LOG_LEVEL):
|
|||
|
||||
# Does 'log_level' have the correct format?
|
||||
# Raise 'tuf.FormatError' if there is a mismatch.
|
||||
tuf.formats.LENGTH_SCHEMA.check_match(log_level)
|
||||
tuf.formats.LOGLEVEL_SCHEMA.check_match(log_level)
|
||||
|
||||
file_handler.setLevel(log_level)
|
||||
|
||||
|
|
@ -240,7 +253,7 @@ def set_console_log_level(log_level=_DEFAULT_CONSOLE_LOG_LEVEL):
|
|||
|
||||
# Does 'log_level' have the correct format?
|
||||
# Raise 'tuf.FormatError' if there is a mismatch.
|
||||
tuf.formats.LENGTH_SCHEMA.check_match(log_level)
|
||||
tuf.formats.LOGLEVEL_SCHEMA.check_match(log_level)
|
||||
|
||||
# Assign to the global console_handler object.
|
||||
global console_handler
|
||||
|
|
@ -279,7 +292,7 @@ def add_console_handler(log_level=_DEFAULT_CONSOLE_LOG_LEVEL):
|
|||
|
||||
# Does 'log_level' have the correct format?
|
||||
# Raise 'tuf.FormatError' if there is a mismatch.
|
||||
tuf.formats.LENGTH_SCHEMA.check_match(log_level)
|
||||
tuf.formats.LOGLEVEL_SCHEMA.check_match(log_level)
|
||||
|
||||
# Assign to the global console_handler object.
|
||||
global console_handler
|
||||
|
|
@ -287,7 +300,6 @@ def add_console_handler(log_level=_DEFAULT_CONSOLE_LOG_LEVEL):
|
|||
if not console_handler:
|
||||
# Set the console handler for the logger. The built-in console handler will
|
||||
# log messages to 'sys.stderr' and capture 'log_level' messages.
|
||||
# NOTE: This is not thread-safe.
|
||||
console_handler = logging.StreamHandler()
|
||||
# Get our filter for the console handler.
|
||||
console_filter = ConsoleFilter()
|
||||
|
|
@ -329,7 +341,6 @@ def remove_console_handler():
|
|||
|
||||
if console_handler:
|
||||
logger.removeHandler(console_handler)
|
||||
# NOTE: This is not thread-safe.
|
||||
console_handler = None
|
||||
logger.debug('Removed a console handler.')
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue