diff options
author | cclauss <cclauss@bluewin.ch> | 2017-09-01 17:40:29 +0200 |
---|---|---|
committer | James E. King, III <jking@apache.org> | 2017-09-24 06:04:15 -0700 |
commit | 4bd3682c79bcbd793f066bfab4d9bb1c1437b722 (patch) | |
tree | 106691a557c03bebf95aca7709c844027e225efc /contrib | |
parent | 9ce1fd9aee00e15abcd81b671594881ee9e1e5c3 (diff) | |
download | thrift-4bd3682c79bcbd793f066bfab4d9bb1c1437b722.tar.gz |
THRIFT-4309: Python print() function
Client: py
This closes #1339
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py | 33 | ||||
-rwxr-xr-x | contrib/zeromq/test-client.py | 2 |
2 files changed, 16 insertions, 19 deletions
diff --git a/contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py b/contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py index 7d5d23179..5c8f409c1 100644 --- a/contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py +++ b/contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python # # Licensed to the Apache Software Foundation (ASF) under one @@ -19,6 +19,7 @@ # under the License. # +from __future__ import print_function import sys import os from optparse import OptionParser @@ -57,24 +58,20 @@ def service_ctrl( msg = fb_status_string(status) if (len(status_details)): msg += " - %s" % status_details - print msg - - if (status == fb_status.ALIVE): - return 2 - else: - return 3 + print(msg) + return 2 if status == fb_status.ALIVE else 3 except: - print "Failed to get status" + print("Failed to get status") return 3 # scalar commands if command in ["version", "alive", "name"]: try: result = fb303_wrapper(command, port, trans_factory, prot_factory) - print result + print(result) return 0 except: - print "failed to get ", command + print("failed to get ", command) return 3 # counters @@ -82,10 +79,10 @@ def service_ctrl( try: counters = fb303_wrapper('counters', port, trans_factory, prot_factory) for counter in counters: - print "%s: %d" % (counter.encode('utf-8'), counters[counter]) + print("%s: %d" % (counter.encode('utf-8'), counters[counter])) return 0 except: - print "failed to get counters" + print("failed to get counters") return 3 # Only root should be able to run the following commands @@ -96,19 +93,19 @@ def service_ctrl( fb303_wrapper(command, port, trans_factory, prot_factory) return 0 except: - print "failed to tell the service to ", command + print("failed to tell the service to ", command) return 3 else: if command in ["stop", "reload"]: - print "root privileges are required to stop or reload the service." + print("root privileges are required to stop or reload the service.") return 4 - print "The following commands are available:" + print("The following commands are available:") for command in ["counters", "name", "version", "alive", "status"]: - print "\t%s" % command - print "The following commands are available for users with root privileges:" + print("\t%s" % command) + print("The following commands are available for users with root privileges:") for command in ["stop", "reload"]: - print "\t%s" % command + print("\t%s" % command) return 0 diff --git a/contrib/zeromq/test-client.py b/contrib/zeromq/test-client.py index 753b132d8..55c23e0a0 100755 --- a/contrib/zeromq/test-client.py +++ b/contrib/zeromq/test-client.py @@ -29,7 +29,7 @@ def main(args): time.sleep(0.05) else: value = client.get() - print value + print(value) if __name__ == "__main__": |