Use Python 3.x compatible syntax constructs
Avoid print operator, deprected except and
other things covered by statical checks.
Change-Id: I89f9608b977b2d4567300ec82558284dac347c9a
diff --git a/tools/find_stack_traces.py b/tools/find_stack_traces.py
index 3129484..0ce1500 100755
--- a/tools/find_stack_traces.py
+++ b/tools/find_stack_traces.py
@@ -110,7 +110,7 @@
def usage():
- print """
+ print("""
Usage: find_stack_traces.py <logurl>
Hunts for stack traces in a devstack run. Must provide it a base log url
@@ -118,20 +118,20 @@
Returns a report listing stack traces out of the various files where
they are found.
-"""
+""")
sys.exit(0)
def print_stats(items, fname, verbose=False):
errors = len(filter(lambda x: x.level == "ERROR", items))
traces = len(filter(lambda x: x.level == "TRACE", items))
- print "%d ERRORS found in %s" % (errors, fname)
- print "%d TRACES found in %s" % (traces, fname)
+ print("%d ERRORS found in %s" % (errors, fname))
+ print("%d TRACES found in %s" % (traces, fname))
if verbose:
for item in items:
- print item
- print "\n\n"
+ print(item)
+ print("\n\n")
def main():
diff --git a/tools/skip_tracker.py b/tools/skip_tracker.py
index c7b0033..1ed6961 100755
--- a/tools/skip_tracker.py
+++ b/tools/skip_tracker.py
@@ -118,8 +118,8 @@
unskips = sorted(set(unskips))
if unskips:
- print "The following bugs have been fixed and the corresponding skips"
- print "should be removed from the test cases:"
- print
+ print("The following bugs have been fixed and the corresponding skips")
+ print("should be removed from the test cases:")
+ print()
for bug in unskips:
- print " %7s" % bug
+ print(" %7s" % bug)
diff --git a/tools/tempest_coverage.py b/tools/tempest_coverage.py
index 5b926f9..ef2eacd 100755
--- a/tools/tempest_coverage.py
+++ b/tools/tempest_coverage.py
@@ -12,7 +12,7 @@
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
-# under the License
+# under the License.
import json
import os
@@ -151,14 +151,14 @@
elif CLI.command == 'stop':
resp, body = coverage_client.stop_coverage()
if not resp['status'] == '200':
- print 'coverage stop failed with: %s:' % (resp['status'] + ': '
- + body)
+ print('coverage stop failed with: %s:' % (resp['status'] + ': '
+ + body))
exit(int(resp['status']))
path = body['path']
if CLI.output:
shutil.copytree(path, CLI.output)
else:
- print "Data files located at: %s" % path
+ print("Data files located at: %s" % path)
elif CLI.command == 'report':
if CLI.xml:
@@ -169,8 +169,8 @@
else:
resp, body = coverage_client.report_coverage(file=CLI.filename)
if not resp['status'] == '200':
- print 'coverage report failed with: %s:' % (resp['status'] + ': '
- + body)
+ print('coverage report failed with: %s:' % (resp['status'] + ': '
+ + body))
exit(int(resp['status']))
path = body['path']
if CLI.output:
@@ -182,10 +182,10 @@
else:
if not CLI.html:
path = os.path.dirname(path)
- print 'Report files located at: %s' % path
+ print('Report files located at: %s' % path)
else:
- print 'Invalid command'
+ print('Invalid command')
exit(1)