Merge salt.cloud.version into salt.version.

This commit is contained in:
Pedro Algarvio 2013-11-20 11:05:06 +00:00
parent 2a97759a3e
commit 2b5061cd91
2 changed files with 11 additions and 38 deletions

View File

@ -1,33 +0,0 @@
# -*- coding: utf-8 -*-
import sys
__version_info__ = (0, 8, 9)
__version__ = '.'.join(map(str, __version_info__))
def versions_report():
libs = (
("Salt", "salt", "__version__"),
("Apache Libcloud", "libcloud", "__version__"),
("PyYAML", "yaml", "__version__"),
)
padding = len(max([lib[0] for lib in libs], key=len)) + 1
fmt = '{0:>{pad}}: {1}'
yield fmt.format("Salt Cloud", __version__, pad=padding)
yield fmt.format(
"Python", sys.version.rsplit('\n')[0].strip(), pad=padding
)
for name, imp, attr in libs:
try:
imp = __import__(imp)
version = getattr(imp, attr)
if not isinstance(version, basestring):
version = '.'.join(map(str, version))
yield fmt.format(name, version, pad=padding)
except ImportError:
yield fmt.format(name, "not installed", pad=padding)

View File

@ -436,11 +436,11 @@ del __get_version
# <---- Dynamic/Runtime Salt Version Information -----------------------------
def versions_information():
def versions_information(include_salt_cloud=False):
'''
Report on all of the versions for dependent software
'''
libs = (
libs = [
('Salt', None, __version__),
('Python', None, sys.version.rsplit('\n')[0].strip()),
('Jinja2', 'jinja2', '__version__'),
@ -451,7 +451,13 @@ def versions_information():
('PyYAML', 'yaml', '__version__'),
('PyZMQ', 'zmq', '__version__'),
('ZMQ', 'zmq', 'zmq_version')
)
]
if include_salt_cloud:
libs.append(
('Apache Libcloud', 'libcloud', '__version__'),
)
for name, imp, attr in libs:
if imp is None:
yield name, attr
@ -468,11 +474,11 @@ def versions_information():
yield name, None
def versions_report():
def versions_report(include_salt_cloud=False):
'''
Yield each library properly formatted for a console clean output.
'''
libs = list(versions_information())
libs = list(versions_information(include_salt_cloud=include_salt_cloud))
padding = max(len(lib[0]) for lib in libs) + 1