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