[pkg-eucalyptus-commits] [SCM] managing cloud instances for Eucalyptus branch, master, updated. 3.0.0-alpha3-257-g1da8e3a

Garrett Holmstrom gholms at fedoraproject.org
Sun Jun 16 02:30:02 UTC 2013


The following commit has been merged in the master branch:
commit 6e3f8c13d55ea4412756bccea26efc929c4c35d7
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date:   Sun Feb 3 01:19:54 2013 -0800

    Clean up version and user-agent handling

diff --git a/euca2ools/__init__.py b/euca2ools/__init__.py
index fc6875d..4763196 100644
--- a/euca2ools/__init__.py
+++ b/euca2ools/__init__.py
@@ -32,4 +32,3 @@
 #       : Mitch Garnaat mgarnaat at eucalyptus.com
 
 __version__  = 'devel'
-__codename__ = 'Sparta'
diff --git a/euca2ools/commands/__init__.py b/euca2ools/commands/__init__.py
index b1f3d94..b8ac0a1 100644
--- a/euca2ools/commands/__init__.py
+++ b/euca2ools/commands/__init__.py
@@ -33,11 +33,11 @@ import os.path
 import platform
 import requestbuilder.command
 import requestbuilder.request
-from .. import __version__, __codename__
+import requests
+import sys
+from .. import __version__
 
 class Euca2oolsCommand(requestbuilder.command.BaseCommand):
-    VERSION = 'euca2ools {0} ({1})'.format(__version__, __codename__)
-
     def __init__(self, **kwargs):
         self._config_files = None
         requestbuilder.request.BaseCommand.__init__(self, **kwargs)
@@ -50,8 +50,9 @@ class Euca2oolsCommand(requestbuilder.command.BaseCommand):
             self._config_files.extend(sorted(glob.glob(user_glob)))
         return self._config_files
 
-class Euca2oolsRequest(requestbuilder.request.BaseRequest):
-    VERSION = 'euca2ools {0} ({1})'.format(__version__, __codename__)
+    @staticmethod
+    def print_version_and_exit():
+        _print_version_and_exit()
 
     def __init__(self, **kwargs):
         self._config_files = None
@@ -68,12 +69,48 @@ class Euca2oolsRequest(requestbuilder.request.BaseRequest):
 
     @property
     def user_agent(self):
-        if not self.__user_agent:
-            template = ('euca2ools/{ver} ({os} {osver}; {python} {pyver}) '
-                        'requestbuilder/{rqver}')
-            self.__user_agent = template.format(ver=__version__,
-                    os=platform.uname()[0], osver=platform.uname()[2],
-                    python=platform.python_implementation(),
-                    pyver=platform.python_version(),
-                    rqver=requestbuilder.__version__)
+        if self.__user_agent is None:
+            user_agent_bits = ['euca2ools/{0}'.format(__version__)]
+
+            tokens = []
+            impl = platform.python_implementation()
+            if impl == 'PyPy':
+                impl_version = '{0}.{1}.{2}'.format(
+                        sys.pypy_version_info.major,
+                        sys.pypy_version_info.minor,
+                        sys.pypy_version_info.micro)
+                if sys.pypy_version_info.releaselevel != 'final':
+                    impl_version += sys.pypy_version_info.releaselevel
+            else:
+                # I'm guessing for non-CPython implementations; feel free to
+                # submit patches or the needed implementation-specific API
+                # references.
+                impl_version = platform.python_version()
+            tokens.append('{0} {1}'.format(impl, impl_version))
+            plat = []
+            try:
+                plat.append(platform.system())
+                plat.append(platform.release())
+            except IOError:
+                pass
+            if plat:
+                tokens.append(' '.join(plat))
+            tokens.append(platform.machine())
+            user_agent_bits.append('({0})'.format('; '.join(tokens)))
+
+            user_agent_bits.append('requestbuilder/{0}'.format(
+                    requestbuilder.__version__))
+            user_agent_bits.append('requests/{0}'.format(requests.__version__))
+            self.__user_agent = ' '.join(user_agent_bits)
         return self.__user_agent
+
+    @staticmethod
+    def print_version_and_exit():
+        _print_version_and_exit()
+
+def _print_version_and_exit():
+    print >> sys.stderr, 'euca2ools {0} (Sparta)'.format(__version__)
+    if os.path.isfile('/etc/eucalyptus/eucalyptus-version'):
+        with open('/etc/eucalyptus/eucalyptus-version') as version_file:
+            print 'eucalyptus {0}'.format(version_file.readline().strip())
+    sys.exit()

-- 
managing cloud instances for Eucalyptus



More information about the pkg-eucalyptus-commits mailing list