summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-03-25 08:33:10 +0000
committerGerrit Code Review <review@openstack.org>2013-03-25 08:33:10 +0000
commit1a5ee2e695c652c93ef32771bb92e419d9715cc6 (patch)
treeddf7811fef3481bea41b77aa3cdb441365cbc81c
parentace737b1a25d03136b22b4150aae64e0384a2546 (diff)
parentf665d798234c19cccc148a178e94c3717ba8bd6e (diff)
downloadnova-1a5ee2e695c652c93ef32771bb92e419d9715cc6.tar.gz
nova-1a5ee2e695c652c93ef32771bb92e419d9715cc6.tar.xz
nova-1a5ee2e695c652c93ef32771bb92e419d9715cc6.zip
Merge "Sync everything from oslo-incubator."
-rwxr-xr-xbin/nova-rootwrap2
-rw-r--r--nova/openstack/common/context.py8
-rw-r--r--nova/openstack/common/db/api.py2
-rw-r--r--nova/openstack/common/eventlet_backdoor.py2
-rw-r--r--nova/openstack/common/excutils.py2
-rw-r--r--nova/openstack/common/fileutils.py2
-rw-r--r--nova/openstack/common/importutils.py2
-rw-r--r--nova/openstack/common/local.py2
-rw-r--r--nova/openstack/common/lockutils.py8
-rw-r--r--nova/openstack/common/log.py40
-rw-r--r--nova/openstack/common/network_utils.py2
-rw-r--r--nova/openstack/common/notifier/__init__.py2
-rw-r--r--nova/openstack/common/notifier/api.py2
-rw-r--r--nova/openstack/common/notifier/log_notifier.py3
-rw-r--r--nova/openstack/common/notifier/no_op_notifier.py2
-rw-r--r--nova/openstack/common/notifier/rpc_notifier.py2
-rw-r--r--nova/openstack/common/notifier/rpc_notifier2.py2
-rw-r--r--nova/openstack/common/notifier/test_notifier.py2
-rw-r--r--nova/openstack/common/plugin/__init__.py2
-rw-r--r--nova/openstack/common/plugin/callbackplugin.py2
-rw-r--r--nova/openstack/common/plugin/plugin.py2
-rw-r--r--nova/openstack/common/plugin/pluginmanager.py2
-rw-r--r--nova/openstack/common/policy.py2
-rw-r--r--nova/openstack/common/processutils.py2
-rw-r--r--nova/openstack/common/rootwrap/__init__.py2
-rw-r--r--nova/openstack/common/rootwrap/filters.py2
-rw-r--r--nova/openstack/common/rootwrap/wrapper.py2
-rw-r--r--nova/openstack/common/setup.py56
-rw-r--r--nova/openstack/common/timeutils.py18
-rw-r--r--tools/flakes.py19
30 files changed, 129 insertions, 69 deletions
diff --git a/bin/nova-rootwrap b/bin/nova-rootwrap
index e42f383dc..a554d8621 100755
--- a/bin/nova-rootwrap
+++ b/bin/nova-rootwrap
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright (c) 2011 OpenStack Foundation
+# Copyright (c) 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/context.py b/nova/openstack/common/context.py
index 709ce4d45..e9cfd73cc 100644
--- a/nova/openstack/common/context.py
+++ b/nova/openstack/common/context.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -37,9 +37,9 @@ class RequestContext(object):
accesses the system, as well as additional request information.
"""
- def __init__(self, auth_tok=None, user=None, tenant=None, is_admin=False,
+ def __init__(self, auth_token=None, user=None, tenant=None, is_admin=False,
read_only=False, show_deleted=False, request_id=None):
- self.auth_tok = auth_tok
+ self.auth_token = auth_token
self.user = user
self.tenant = tenant
self.is_admin = is_admin
@@ -55,7 +55,7 @@ class RequestContext(object):
'is_admin': self.is_admin,
'read_only': self.read_only,
'show_deleted': self.show_deleted,
- 'auth_token': self.auth_tok,
+ 'auth_token': self.auth_token,
'request_id': self.request_id}
diff --git a/nova/openstack/common/db/api.py b/nova/openstack/common/db/api.py
index 90a200875..86db0c3da 100644
--- a/nova/openstack/common/db/api.py
+++ b/nova/openstack/common/db/api.py
@@ -39,8 +39,8 @@ import functools
from oslo.config import cfg
-from nova.openstack.common import lockutils
from nova.openstack.common import importutils
+from nova.openstack.common import lockutils
db_opts = [
diff --git a/nova/openstack/common/eventlet_backdoor.py b/nova/openstack/common/eventlet_backdoor.py
index 007676847..c0ad460fe 100644
--- a/nova/openstack/common/eventlet_backdoor.py
+++ b/nova/openstack/common/eventlet_backdoor.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright (c) 2012 OpenStack Foundation
+# Copyright (c) 2012 OpenStack Foundation.
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
diff --git a/nova/openstack/common/excutils.py b/nova/openstack/common/excutils.py
index bfd3fc0ed..e1ca05867 100644
--- a/nova/openstack/common/excutils.py
+++ b/nova/openstack/common/excutils.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# Copyright 2012, Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/fileutils.py b/nova/openstack/common/fileutils.py
index cc52e7d44..b988ad03d 100644
--- a/nova/openstack/common/fileutils.py
+++ b/nova/openstack/common/fileutils.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/importutils.py b/nova/openstack/common/importutils.py
index 8b5c00892..3bd277f47 100644
--- a/nova/openstack/common/importutils.py
+++ b/nova/openstack/common/importutils.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/local.py b/nova/openstack/common/local.py
index a9796bfe7..f1bfc824b 100644
--- a/nova/openstack/common/local.py
+++ b/nova/openstack/common/local.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/lockutils.py b/nova/openstack/common/lockutils.py
index 3270f0473..e1af8bac7 100644
--- a/nova/openstack/common/lockutils.py
+++ b/nova/openstack/common/lockutils.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -32,6 +32,7 @@ from nova.openstack.common.gettextutils import _
from nova.openstack.common import local
from nova.openstack.common import log as logging
+
LOG = logging.getLogger(__name__)
@@ -106,10 +107,10 @@ class _InterProcessLock(object):
class _WindowsLock(_InterProcessLock):
def trylock(self):
- msvcrt.locking(self.lockfile, msvcrt.LK_NBLCK, 1)
+ msvcrt.locking(self.lockfile.fileno(), msvcrt.LK_NBLCK, 1)
def unlock(self):
- msvcrt.locking(self.lockfile, msvcrt.LK_UNLCK, 1)
+ msvcrt.locking(self.lockfile.fileno(), msvcrt.LK_UNLCK, 1)
class _PosixLock(_InterProcessLock):
@@ -206,7 +207,6 @@ def synchronized(name, lock_file_prefix, external=False, lock_path=None):
local_lock_path = tempfile.mkdtemp()
if not os.path.exists(local_lock_path):
- cleanup_dir = True
fileutils.ensure_tree(local_lock_path)
# NOTE(mikal): the lock name cannot contain directory
diff --git a/nova/openstack/common/log.py b/nova/openstack/common/log.py
index dfad9919f..e40a803c5 100644
--- a/nova/openstack/common/log.py
+++ b/nova/openstack/common/log.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
@@ -29,6 +29,7 @@ It also allows setting of formatting information through conf.
"""
+import ConfigParser
import cStringIO
import inspect
import itertools
@@ -87,11 +88,11 @@ logging_cli_opts = [
metavar='PATH',
deprecated_name='logfile',
help='(Optional) Name of log file to output to. '
- 'If not set, logging will go to stdout.'),
+ 'If no default is set, logging will go to stdout.'),
cfg.StrOpt('log-dir',
deprecated_name='logdir',
- help='(Optional) The directory to keep log files in '
- '(will be prepended to --log-file)'),
+ help='(Optional) The base directory used for relative '
+ '--log-file paths'),
cfg.BoolOpt('use-syslog',
default=False,
help='Use syslog for logging.'),
@@ -323,12 +324,32 @@ def _create_logging_excepthook(product_name):
return logging_excepthook
+class LogConfigError(Exception):
+
+ message = _('Error loading logging config %(log_config)s: %(err_msg)s')
+
+ def __init__(self, log_config, err_msg):
+ self.log_config = log_config
+ self.err_msg = err_msg
+
+ def __str__(self):
+ return self.message % dict(log_config=self.log_config,
+ err_msg=self.err_msg)
+
+
+def _load_log_config(log_config):
+ try:
+ logging.config.fileConfig(log_config)
+ except ConfigParser.Error, exc:
+ raise LogConfigError(log_config, str(exc))
+
+
def setup(product_name):
"""Setup logging."""
if CONF.log_config:
- logging.config.fileConfig(CONF.log_config)
+ _load_log_config(CONF.log_config)
else:
- _setup_logging_from_conf(product_name)
+ _setup_logging_from_conf()
sys.excepthook = _create_logging_excepthook(product_name)
@@ -362,8 +383,8 @@ def _find_facility_from_conf():
return facility
-def _setup_logging_from_conf(product_name):
- log_root = getLogger(product_name).logger
+def _setup_logging_from_conf():
+ log_root = getLogger(None).logger
for handler in log_root.handlers:
log_root.removeHandler(handler)
@@ -401,7 +422,8 @@ def _setup_logging_from_conf(product_name):
if CONF.log_format:
handler.setFormatter(logging.Formatter(fmt=CONF.log_format,
datefmt=datefmt))
- handler.setFormatter(LegacyFormatter(datefmt=datefmt))
+ else:
+ handler.setFormatter(LegacyFormatter(datefmt=datefmt))
if CONF.debug:
log_root.setLevel(logging.DEBUG)
diff --git a/nova/openstack/common/network_utils.py b/nova/openstack/common/network_utils.py
index 65299b009..5224e01aa 100644
--- a/nova/openstack/common/network_utils.py
+++ b/nova/openstack/common/network_utils.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright 2012 OpenStack Foundation
+# Copyright 2012 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/notifier/__init__.py b/nova/openstack/common/notifier/__init__.py
index 31285c4fc..45c3b46ae 100644
--- a/nova/openstack/common/notifier/__init__.py
+++ b/nova/openstack/common/notifier/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/notifier/api.py b/nova/openstack/common/notifier/api.py
index cb0a38b71..54da07b7e 100644
--- a/nova/openstack/common/notifier/api.py
+++ b/nova/openstack/common/notifier/api.py
@@ -1,4 +1,4 @@
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/notifier/log_notifier.py b/nova/openstack/common/notifier/log_notifier.py
index 51e488c94..b5c08fcfa 100644
--- a/nova/openstack/common/notifier/log_notifier.py
+++ b/nova/openstack/common/notifier/log_notifier.py
@@ -1,4 +1,4 @@
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -18,6 +18,7 @@ from oslo.config import cfg
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
+
CONF = cfg.CONF
diff --git a/nova/openstack/common/notifier/no_op_notifier.py b/nova/openstack/common/notifier/no_op_notifier.py
index d22d02072..bc7a56ca7 100644
--- a/nova/openstack/common/notifier/no_op_notifier.py
+++ b/nova/openstack/common/notifier/no_op_notifier.py
@@ -1,4 +1,4 @@
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/notifier/rpc_notifier.py b/nova/openstack/common/notifier/rpc_notifier.py
index a119b2b7a..c258e49f8 100644
--- a/nova/openstack/common/notifier/rpc_notifier.py
+++ b/nova/openstack/common/notifier/rpc_notifier.py
@@ -1,4 +1,4 @@
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/notifier/rpc_notifier2.py b/nova/openstack/common/notifier/rpc_notifier2.py
index d2ad74fb4..5e02f8fbb 100644
--- a/nova/openstack/common/notifier/rpc_notifier2.py
+++ b/nova/openstack/common/notifier/rpc_notifier2.py
@@ -1,4 +1,4 @@
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/notifier/test_notifier.py b/nova/openstack/common/notifier/test_notifier.py
index 2e392f8b9..96c1746bf 100644
--- a/nova/openstack/common/notifier/test_notifier.py
+++ b/nova/openstack/common/notifier/test_notifier.py
@@ -1,4 +1,4 @@
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/plugin/__init__.py b/nova/openstack/common/plugin/__init__.py
index bf3075ddd..b706747cf 100644
--- a/nova/openstack/common/plugin/__init__.py
+++ b/nova/openstack/common/plugin/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2012 OpenStack Foundation
+# Copyright 2012 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/plugin/callbackplugin.py b/nova/openstack/common/plugin/callbackplugin.py
index 371819189..c08ee69fb 100644
--- a/nova/openstack/common/plugin/callbackplugin.py
+++ b/nova/openstack/common/plugin/callbackplugin.py
@@ -1,4 +1,4 @@
-# Copyright 2012 OpenStack Foundation
+# Copyright 2012 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/plugin/plugin.py b/nova/openstack/common/plugin/plugin.py
index 66feb000b..4d6d9a464 100644
--- a/nova/openstack/common/plugin/plugin.py
+++ b/nova/openstack/common/plugin/plugin.py
@@ -1,4 +1,4 @@
-# Copyright 2012 OpenStack Foundation
+# Copyright 2012 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/plugin/pluginmanager.py b/nova/openstack/common/plugin/pluginmanager.py
index b789c2c7c..4730ea1cd 100644
--- a/nova/openstack/common/plugin/pluginmanager.py
+++ b/nova/openstack/common/plugin/pluginmanager.py
@@ -1,4 +1,4 @@
-# Copyright 2012 OpenStack Foundation
+# Copyright 2012 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/policy.py b/nova/openstack/common/policy.py
index 8ed40477e..028a970fe 100644
--- a/nova/openstack/common/policy.py
+++ b/nova/openstack/common/policy.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright (c) 2012 OpenStack Foundation
+# Copyright (c) 2012 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/processutils.py b/nova/openstack/common/processutils.py
index 8ace63176..b2b75abf9 100644
--- a/nova/openstack/common/processutils.py
+++ b/nova/openstack/common/processutils.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/rootwrap/__init__.py b/nova/openstack/common/rootwrap/__init__.py
index f0f23d6a2..2d32e4ef3 100644
--- a/nova/openstack/common/rootwrap/__init__.py
+++ b/nova/openstack/common/rootwrap/__init__.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright (c) 2011 OpenStack Foundation
+# Copyright (c) 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/rootwrap/filters.py b/nova/openstack/common/rootwrap/filters.py
index 8e92d6bb4..eadda256c 100644
--- a/nova/openstack/common/rootwrap/filters.py
+++ b/nova/openstack/common/rootwrap/filters.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright (c) 2011 OpenStack Foundation
+# Copyright (c) 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/rootwrap/wrapper.py b/nova/openstack/common/rootwrap/wrapper.py
index 7dc533e1e..bbcbd9bd3 100644
--- a/nova/openstack/common/rootwrap/wrapper.py
+++ b/nova/openstack/common/rootwrap/wrapper.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright (c) 2011 OpenStack Foundation
+# Copyright (c) 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/nova/openstack/common/setup.py b/nova/openstack/common/setup.py
index de008ab15..030df61c9 100644
--- a/nova/openstack/common/setup.py
+++ b/nova/openstack/common/setup.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# Copyright 2012-2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
@@ -43,6 +43,11 @@ def parse_mailmap(mailmap='.mailmap'):
return mapping
+def _parse_git_mailmap(git_dir, mailmap='.mailmap'):
+ mailmap = os.path.join(os.path.dirname(git_dir), mailmap)
+ return parse_mailmap(mailmap)
+
+
def canonicalize_emails(changelog, mapping):
"""Takes in a string and an email alias mapping and replaces all
instances of the aliases in the string with their real email.
@@ -117,9 +122,9 @@ def _run_shell_command(cmd, throw_on_error=False):
output = subprocess.Popen(["/bin/sh", "-c", cmd],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+ out = output.communicate()
if output.returncode and throw_on_error:
raise Exception("%s returned %d" % cmd, output.returncode)
- out = output.communicate()
if len(out) == 0:
return None
if len(out[0].strip()) == 0:
@@ -127,14 +132,26 @@ def _run_shell_command(cmd, throw_on_error=False):
return out[0].strip()
+def _get_git_directory():
+ parent_dir = os.path.dirname(__file__)
+ while True:
+ git_dir = os.path.join(parent_dir, '.git')
+ if os.path.exists(git_dir):
+ return git_dir
+ parent_dir, child = os.path.split(parent_dir)
+ if not child: # reached to root dir
+ return None
+
+
def write_git_changelog():
"""Write a changelog based on the git changelog."""
new_changelog = 'ChangeLog'
+ git_dir = _get_git_directory()
if not os.getenv('SKIP_WRITE_GIT_CHANGELOG'):
- if os.path.isdir('.git'):
- git_log_cmd = 'git log --stat'
+ if git_dir:
+ git_log_cmd = 'git --git-dir=%s log' % git_dir
changelog = _run_shell_command(git_log_cmd)
- mailmap = parse_mailmap()
+ mailmap = _parse_git_mailmap(git_dir)
with open(new_changelog, "w") as changelog_file:
changelog_file.write(canonicalize_emails(changelog, mailmap))
else:
@@ -146,13 +163,15 @@ def generate_authors():
jenkins_email = 'jenkins@review.(openstack|stackforge).org'
old_authors = 'AUTHORS.in'
new_authors = 'AUTHORS'
+ git_dir = _get_git_directory()
if not os.getenv('SKIP_GENERATE_AUTHORS'):
- if os.path.isdir('.git'):
+ if git_dir:
# don't include jenkins email address in AUTHORS file
- git_log_cmd = ("git log --format='%aN <%aE>' | sort -u | "
+ git_log_cmd = ("git --git-dir=" + git_dir +
+ " log --format='%aN <%aE>' | sort -u | "
"egrep -v '" + jenkins_email + "'")
changelog = _run_shell_command(git_log_cmd)
- mailmap = parse_mailmap()
+ mailmap = _parse_git_mailmap(git_dir)
with open(new_authors, 'w') as new_authors_fh:
new_authors_fh.write(canonicalize_emails(changelog, mailmap))
if os.path.exists(old_authors):
@@ -258,19 +277,21 @@ def get_cmdclass():
return cmdclass
-def _get_revno():
+def _get_revno(git_dir):
"""Return the number of commits since the most recent tag.
We use git-describe to find this out, but if there are no
tags then we fall back to counting commits since the beginning
of time.
"""
- describe = _run_shell_command("git describe --always")
+ describe = _run_shell_command(
+ "git --git-dir=%s describe --always" % git_dir)
if "-" in describe:
return describe.rsplit("-", 2)[-2]
# no tags found
- revlist = _run_shell_command("git rev-list --abbrev-commit HEAD")
+ revlist = _run_shell_command(
+ "git --git-dir=%s rev-list --abbrev-commit HEAD" % git_dir)
return len(revlist.splitlines())
@@ -279,18 +300,21 @@ def _get_version_from_git(pre_version):
revision if there is one, or tag plus number of additional revisions
if the current revision has no tag."""
- if os.path.isdir('.git'):
+ git_dir = _get_git_directory()
+ if git_dir:
if pre_version:
try:
return _run_shell_command(
- "git describe --exact-match",
+ "git --git-dir=" + git_dir + " describe --exact-match",
throw_on_error=True).replace('-', '.')
except Exception:
- sha = _run_shell_command("git log -n1 --pretty=format:%h")
- return "%s.a%s.g%s" % (pre_version, _get_revno(), sha)
+ sha = _run_shell_command(
+ "git --git-dir=" + git_dir + " log -n1 --pretty=format:%h")
+ return "%s.a%s.g%s" % (pre_version, _get_revno(git_dir), sha)
else:
return _run_shell_command(
- "git describe --always").replace('-', '.')
+ "git --git-dir=" + git_dir + " describe --always").replace(
+ '-', '.')
return None
diff --git a/nova/openstack/common/timeutils.py b/nova/openstack/common/timeutils.py
index 2691dc456..609436590 100644
--- a/nova/openstack/common/timeutils.py
+++ b/nova/openstack/common/timeutils.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright 2011 OpenStack Foundation
+# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -25,18 +25,22 @@ import datetime
import iso8601
-TIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
-PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
+# ISO 8601 extended time format with microseconds
+_ISO8601_TIME_FORMAT_SUBSECOND = '%Y-%m-%dT%H:%M:%S.%f'
+_ISO8601_TIME_FORMAT = '%Y-%m-%dT%H:%M:%S'
+PERFECT_TIME_FORMAT = _ISO8601_TIME_FORMAT_SUBSECOND
-def isotime(at=None):
+def isotime(at=None, subsecond=False):
"""Stringify time in ISO 8601 format"""
if not at:
at = utcnow()
- str = at.strftime(TIME_FORMAT)
+ st = at.strftime(_ISO8601_TIME_FORMAT
+ if not subsecond
+ else _ISO8601_TIME_FORMAT_SUBSECOND)
tz = at.tzinfo.tzname(None) if at.tzinfo else 'UTC'
- str += ('Z' if tz == 'UTC' else tz)
- return str
+ st += ('Z' if tz == 'UTC' else tz)
+ return st
def parse_isotime(timestr):
diff --git a/tools/flakes.py b/tools/flakes.py
index 7f96116ca..191bd6eab 100644
--- a/tools/flakes.py
+++ b/tools/flakes.py
@@ -4,12 +4,21 @@
Synced in from openstack-common
"""
+
+__all__ = ['main']
+
+import __builtin__ as builtins
import sys
-import pyflakes.checker
-from pyflakes.scripts import pyflakes
+import pyflakes.api
+from pyflakes import checker
+
+
+def main():
+ checker.Checker.builtIns = (set(dir(builtins)) |
+ set(['_']) |
+ set(checker._MAGIC_GLOBALS))
+ sys.exit(pyflakes.api.main())
if __name__ == "__main__":
- orig_builtins = set(pyflakes.checker._MAGIC_GLOBALS)
- pyflakes.checker._MAGIC_GLOBALS = orig_builtins | set(['_'])
- sys.exit(pyflakes.main())
+ main()