Skip to content

Commit

Permalink
Use built-in print() instead of print statement
Browse files Browse the repository at this point in the history
In python 3 print statement is not supported, so we should use
only print() functions.

Fixes bug 1226943

Change-Id: I206fe870eea21522e28318b9cfa062239e54c391
  • Loading branch information
glongwave committed Sep 21, 2013
1 parent d1cb53d commit 0135548
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
11 changes: 6 additions & 5 deletions doc/source/conf.py
Expand Up @@ -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
Expand All @@ -31,7 +32,7 @@ def find_autodoc_modules(module_name, sourcedir):
"""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"):
Expand Down Expand Up @@ -80,7 +81,7 @@ def find_autodoc_modules(module_name, sourcedir):
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)
Expand All @@ -100,8 +101,8 @@ def find_autodoc_modules(module_name, sourcedir):
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),))
Expand All @@ -120,7 +121,7 @@ def find_autodoc_modules(module_name, sourcedir):
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))


Expand Down
3 changes: 2 additions & 1 deletion tools/make_test_data.py
Expand Up @@ -19,6 +19,7 @@

"""Command line tool for creating test data for ceilometer.
"""
from __future__ import print_function

import argparse
import datetime
Expand Down Expand Up @@ -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

Expand Down
8 changes: 5 additions & 3 deletions tools/release-bugs.py
Expand Up @@ -19,14 +19,16 @@

"""Command line tool for releasing Ceilometer bugs."""

from __future__ import print_function

import argparse
import sys

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)


Expand Down Expand Up @@ -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.
Expand Down
31 changes: 16 additions & 15 deletions tools/show_data.py
Expand Up @@ -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

Expand All @@ -26,7 +27,7 @@

def show_users(db, args):
for u in sorted(db.get_users()):
print u
print(u)


def show_resources(db, args):
Expand All @@ -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,
Expand All @@ -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):
Expand All @@ -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,
Expand All @@ -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 = {
Expand Down

0 comments on commit 0135548

Please sign in to comment.