diff --git a/doc/source/conf.py b/doc/source/conf.py index 9d0180791..68893720e 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -11,6 +11,7 @@ # # All configuration values have a default; values that are commented out # serve to show the default. +from __future__ import print_function import sys import os @@ -31,7 +32,7 @@ def write_autodoc_index(): """Return a list of modules in the SOURCE directory.""" modlist = [] os.chdir(os.path.join(sourcedir, module_name)) - print "SEARCHING %s" % sourcedir + print("SEARCHING %s" % sourcedir) for root, dirs, files in os.walk("."): for filename in files: if filename.endswith(".py"): @@ -80,7 +81,7 @@ def write_autodoc_index(): if any([module.startswith(exclude) for exclude in EXCLUDED_MODULES]): - print "Excluded module %s." % module + print("Excluded module %s." % module) continue mod_path = os.path.join(path, *module.split(".")) generated_file = os.path.join(MOD_DIR, "%s.rst" % module) @@ -100,8 +101,8 @@ def write_autodoc_index(): if not os.access(generated_file, os.F_OK) or \ os.stat(generated_file).st_mtime < \ os.stat(source_file).st_mtime: - print "Module %s updated, generating new documentation." \ - % module + print("Module %s updated, generating new documentation." \ + % module) FILEOUT = open(generated_file, "w") header = "The :mod:`%s` Module" % module FILEOUT.write("%s\n" % ("=" * len(header),)) @@ -120,7 +121,7 @@ def write_autodoc_index(): for directory, subdirs, files in list(os.walk(RSTDIR)): for old_file in files: if old_file not in CURRENT_SOURCES.get(directory, []): - print "Removing outdated file for %s" % old_file + print("Removing outdated file for %s" % old_file) os.remove(os.path.join(directory, old_file)) diff --git a/tools/make_test_data.py b/tools/make_test_data.py index 34176b51c..7a8e4f12f 100755 --- a/tools/make_test_data.py +++ b/tools/make_test_data.py @@ -19,6 +19,7 @@ """Command line tool for creating test data for ceilometer. """ +from __future__ import print_function import argparse import datetime @@ -137,7 +138,7 @@ def main(): n += 1 timestamp = timestamp + increment - print 'Added %d new events' % n + print('Added %d new events' % n) return 0 diff --git a/tools/release-bugs.py b/tools/release-bugs.py index a7835283d..ee3ca9b64 100755 --- a/tools/release-bugs.py +++ b/tools/release-bugs.py @@ -19,6 +19,8 @@ """Command line tool for releasing Ceilometer bugs.""" +from __future__ import print_function + import argparse import sys @@ -26,7 +28,7 @@ try: from launchpadlib.launchpad import Launchpad from launchpadlib.uris import LPNET_SERVICE_ROOT as SERVICE_ROOT except ImportError: - print "Can't import launchpadlib." + print("Can't import launchpadlib.") sys.exit(1) @@ -56,14 +58,14 @@ def main(): status=PRE_RELEASE_STATUS, milestone=milestone) bug_count = len(bugs_for_milestone) if bug_count == 0: - print "No bugs to release for milestone %s" % milestone.name + print("No bugs to release for milestone %s" % milestone.name) sys.exit(0) mark_released = raw_input(RELEASE_PROMPT.format( bug_count=bug_count, pre_release_status=PRE_RELEASE_STATUS, milestone_title=milestone.name)) if mark_released.lower() != "y": - print "Not releasing bugs." + print("Not releasing bugs.") sys.exit(0) for bug_task in bugs_for_milestone: # We re-load the bugtask to avoid having bug 369293 bite us. diff --git a/tools/show_data.py b/tools/show_data.py index 5aba6b871..d5c48003f 100755 --- a/tools/show_data.py +++ b/tools/show_data.py @@ -16,6 +16,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +from __future__ import print_function import sys @@ -26,7 +27,7 @@ from ceilometer import storage def show_users(db, args): for u in sorted(db.get_users()): - print u + print(u) def show_resources(db, args): @@ -35,11 +36,11 @@ def show_resources(db, args): else: users = sorted(db.get_users()) for u in users: - print u + print(u) for resource in db.get_resources(user=u): - print ' %(resource_id)s %(timestamp)s' % resource + print(' %(resource_id)s %(timestamp)s' % resource) for k, v in sorted(resource['metadata'].iteritems()): - print ' %-10s : %s' % (k, v) + print(' %-10s : %s' % (k, v)) for meter in resource['meter']: totals = db.get_statistics(storage.SampleFilter( user=u, @@ -52,9 +53,9 @@ def show_resources(db, args): value = totals[0]['max'] else: value = totals[0]['sum'] - print ' %s (%s): %s' % \ - (meter['counter_name'], meter['counter_type'], - value) + print(' %s (%s): %s' % \ + (meter['counter_name'], meter['counter_type'], + value)) def show_total_resources(db, args): @@ -63,7 +64,7 @@ def show_total_resources(db, args): else: users = sorted(db.get_users()) for u in users: - print u + print(u) for meter in ['disk', 'cpu', 'instance']: stats = db.get_statistics(storage.SampleFilter( user=u, @@ -73,31 +74,31 @@ def show_total_resources(db, args): total = stats['max'] else: total = stats['sum'] - print ' ', meter, total + print(' ', meter, total) def show_raw(db, args): fmt = ' %(timestamp)s %(counter_name)10s %(counter_volume)s' for u in sorted(db.get_users()): - print u + print(u) for resource in db.get_resources(user=u): - print ' ', resource['resource_id'] + print(' ', resource['resource_id']) for sample in db.get_samples(storage.SampleFilter( user=u, resource=resource['resource_id'], )): - print fmt % sample + print(fmt % sample) def show_help(db, args): - print 'COMMANDS:' + print('COMMANDS:') for name in sorted(COMMANDS.keys()): - print name + print(name) def show_projects(db, args): for u in sorted(db.get_projects()): - print u + print(u) COMMANDS = {