Use built-in print() instead of print statement
In python 3 print statement is not supported, so we should use only print() functions. Fixes bug 1226943 Change-Id: I206fe870eea21522e28318b9cfa062239e54c391
This commit is contained in:
parent
d1cb53db89
commit
0135548dc4
@ -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))
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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 = {
|
||||
|
Loading…
Reference in New Issue
Block a user