From 59b3e0f2700d6a9067bffe045ea335b7abc35a27 Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Thu, 6 Jan 2011 15:08:14 -0500 Subject: pep8 --- nova/log.py | 3 +-- nova/tests/test_log.py | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/nova/log.py b/nova/log.py index 97472b20b..6f5377e87 100644 --- a/nova/log.py +++ b/nova/log.py @@ -74,7 +74,6 @@ flags.DEFINE_bool('use_syslog', False, 'output to syslog') flags.DEFINE_string('logfile', None, 'output to named file') - # A list of things we want to replicate from logging. # levels CRITICAL = logging.CRITICAL @@ -112,7 +111,7 @@ def _dictify_context(context): return None if not isinstance(context, dict) \ and getattr(context, 'to_dict', None): - context = context.to_dict() + context = context.to_dict() return context diff --git a/nova/tests/test_log.py b/nova/tests/test_log.py index d8dd38708..beb1d97cf 100644 --- a/nova/tests/test_log.py +++ b/nova/tests/test_log.py @@ -35,15 +35,16 @@ class RootLoggerTestCase(test.TrialTestCase): def test_handles_context_kwarg(self): self.log.info("foo", context=_fake_context()) - self.assert_(True) # didn't raise exception + self.assert_(True) # didn't raise exception def test_module_level_methods_handle_context_arg(self): log.info("foo", context=_fake_context()) - self.assert_(True) # didn't raise exception + self.assert_(True) # didn't raise exception def test_module_level_audit_handles_context_arg(self): log.audit("foo", context=_fake_context()) - self.assert_(True) # didn't raise exception + self.assert_(True) # didn't raise exception + class NovaFormatterTestCase(test.TrialTestCase): def setUp(self): @@ -76,6 +77,7 @@ class NovaFormatterTestCase(test.TrialTestCase): self.log.debug("baz") self.assertEqual("NOCTXT: baz --DBG\n", self.stream.getvalue()) + class NovaLoggerTestCase(test.TrialTestCase): def setUp(self): super(NovaLoggerTestCase, self).setUp() @@ -93,6 +95,7 @@ class NovaLoggerTestCase(test.TrialTestCase): l = log.getLogger('nova-test.foo') self.assertEqual(log.AUDIT, l.level) + class VerboseLoggerTestCase(test.TrialTestCase): def setUp(self): super(VerboseLoggerTestCase, self).setUp() -- cgit From 13b1374897c59c6e59fe5542ab71b0180aa6fc00 Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Thu, 6 Jan 2011 15:08:26 -0500 Subject: Track version info, and make available for logging. --- nova/log.py | 14 ++++---------- setup.py | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/nova/log.py b/nova/log.py index 97472b20b..aafc2e602 100644 --- a/nova/log.py +++ b/nova/log.py @@ -34,24 +34,19 @@ import logging.handlers import traceback from nova import flags -# TODO(todd): fix after version.py merge -# from nova import version +from nova import version FLAGS = flags.FLAGS -# TODO(todd): fix after version.py merge -# '(%(name)s %(nova_version)s): %(levelname)s ' flags.DEFINE_string('logging_context_format_string', - '(%(name)s): %(levelname)s ' + '(%(name)s %(nova_version)s): %(levelname)s ' '[%(request_id)s %(user)s ' '%(project)s] %(message)s', 'format string to use for log messages') -# TODO(todd): fix after version.py merge -# '(%(name)s %(nova_version)s): %(levelname)s [N/A] ' flags.DEFINE_string('logging_default_format_string', - '(%(name)s): %(levelname)s [N/A] ' + '(%(name)s %(nova_version)s): %(levelname)s [N/A] ' '%(message)s', 'format string to use for log messages') @@ -163,8 +158,7 @@ class NovaLogger(logging.Logger): extra = {} if context: extra.update(_dictify_context(context)) - # TODO(todd): fix after version.py merge - #extra.update({"nova_version": version.string_with_vcs()}) + extra.update({"nova_version": version.string_with_vcs()}) logging.Logger._log(self, level, msg, args, exc_info, extra) def addHandler(self, handler): diff --git a/setup.py b/setup.py index e00911099..6d7cecb70 100644 --- a/setup.py +++ b/setup.py @@ -25,6 +25,45 @@ from sphinx.setup_command import BuildDoc from nova.utils import parse_mailmap, str_dict_replace +NOVA_VERSION = ['2011', '1'] + +VERSIONFILE_DEFAULT_VCS_VERSION = """ +version_info = {"branch_nick": "LOCALBRANCH", "revision_id": "LOCALREVISION"} +""" + +VERSIONFILE_DATA = """ +# below this line automatically generated by setup.py + +YEAR = %r +COUNT = %r +""" % (NOVA_VERSION[0], NOVA_VERSION[1]) + + +VERSIONFILE_DATA += """ + +def string(): + return '.'.join([YEAR, COUNT]) + + +def vcs_version_string(): + return "%s:%s" % (version_info['branch_nick'], version_info['revision_id']) + + +def string_with_vcs(): + return "%s-%s" % (string(), vcs_version_string()) +""" + +with open("nova/version.py", 'w') as version_file: + if os.path.isdir('.bzr'): + vcs_cmd = subprocess.Popen(["bzr", "version-info", "--python"], + stdout=subprocess.PIPE) + vcsversion = vcs_cmd.communicate()[0] + version_file.write(vcsversion) + else: + version_file.write(VERSIONFILE_DEFAULT_VCS_VERSION) + version_file.write(VERSIONFILE_DATA) + + class local_BuildDoc(BuildDoc): def run(self): for builder in ['html', 'man']: -- cgit From f3ea4d876fe0d62dcf63cfdcaf7657949cc4dbcf Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Thu, 6 Jan 2011 15:20:04 -0500 Subject: Add default version file for developers. --- nova/version.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 nova/version.py diff --git a/nova/version.py b/nova/version.py new file mode 100644 index 000000000..fc14b8401 --- /dev/null +++ b/nova/version.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +"""This file is automatically generated by generate_version_info +It uses the current working tree to determine the revision. +So don't edit it. :) +""" + +version_info = {'branch_nick': u'LOCALBRANCH', 'revision_id': 'LOCALREVISION', + 'revno': 0} + +revisions = {} + +file_revisions = {} + + +if __name__ == '__main__': + print 'revision: %(revno)d' % version_info + print 'nick: %(branch_nick)s' % version_info + print 'revision id: %(revision_id)s' % version_info + +# below this line automatically generated by setup.py + +YEAR = '2011' +COUNT = '1-dev' + + +def string(): + return '.'.join([YEAR, COUNT]) + + +def vcs_version_string(): + return "%s:%s" % (version_info['branch_nick'], version_info['revision_id']) + + +def string_with_vcs(): + return "%s-%s" % (string(), vcs_version_string()) -- cgit From 8cdfdd14a03e1356cda4fcbdfbcc528bc7f397bd Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Thu, 6 Jan 2011 15:29:38 -0500 Subject: Let documentation get version from nova/version.py as well. --- doc/source/conf.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 8f1b370cc..61b3749d0 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -60,10 +60,12 @@ copyright = u'2010, United States Government as represented by the Administrator # |version| and |release|, also used in various other places throughout the # built documents. # -# The short X.Y version. -version = '2011.1' +import re +from nova import version as nova_version # The full version, including alpha/beta/rc tags. -release = '2011.1-prerelease' +release = nova_version.string() +# The short X.Y version. +version = re.sub(r'-dev$', '', nova_version.string()) # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -- cgit