From c3a358ed17723e5b8bd367c0fb352a33aa0dc62d Mon Sep 17 00:00:00 2001 From: vladdd Date: Mon, 23 Sep 2013 21:35:14 -0400 Subject: [PATCH 1/6] Update comments about thread safety --- tuf/log.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tuf/log.py b/tuf/log.py index d82f1078..d5816685 100755 --- a/tuf/log.py +++ b/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 + """ @@ -287,7 +294,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 +335,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: From e07bd128b9fb7548132121ce5c260faba1b5bb0a Mon Sep 17 00:00:00 2001 From: vladdd Date: Tue, 1 Oct 2013 15:28:38 -0400 Subject: [PATCH 2/6] Add LOGLEVEL_SCHEMA to tuf.formats log.py previously checked the format of log level arguments with LENGTH_SCHEMA. LOGLEVEL_SCHEMA might be clearer. --- tuf/formats.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tuf/formats.py b/tuf/formats.py index 7142469b..038bf4a0 100755 --- a/tuf/formats.py +++ b/tuf/formats.py @@ -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() From 213b96dfea6678edecb1a95b4ee9125bb935c55b Mon Sep 17 00:00:00 2001 From: vladdd Date: Tue, 1 Oct 2013 15:33:39 -0400 Subject: [PATCH 3/6] Update comments and schema type checked Expand the comments on 'logging.Formatter.converter' to discuss the converter attribute. Modify LENGTH_SCHEMA to LOGLEVEL_SCHEMA. --- tuf/log.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tuf/log.py b/tuf/log.py index d5816685..6ba9ece5 100755 --- a/tuf/log.py +++ b/tuf/log.py @@ -79,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) @@ -184,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) @@ -215,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) @@ -247,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 @@ -286,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 From d8052d13a423d100b068a196299279f8e79a32c0 Mon Sep 17 00:00:00 2001 From: Vladimir Diaz Date: Wed, 9 Oct 2013 14:28:16 -0400 Subject: [PATCH 4/6] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3a92ed4b..41007030 100644 --- a/README.md +++ b/README.md @@ -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. From 36951b8f618fc91b09af2e1e2fed23e556fb28d4 Mon Sep 17 00:00:00 2001 From: Vladimir Diaz Date: Wed, 9 Oct 2013 14:29:06 -0400 Subject: [PATCH 5/6] Update AUTHORS.txt --- AUTHORS.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 384f9c19..1ad513a8 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -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 From dc84e051e6970bbc1c767f594df7d1a3c08b703a Mon Sep 17 00:00:00 2001 From: vladdd Date: Mon, 14 Oct 2013 09:20:49 -0400 Subject: [PATCH 6/6] Update the valid expiration data --- tests/unit/test_quickstart.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_quickstart.py b/tests/unit/test_quickstart.py index fd7e5515..00ddf44e 100755 --- a/tests/unit/test_quickstart.py +++ b/tests/unit/test_quickstart.py @@ -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.