You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2017/09/24 13:05:09 UTC

[2/2] thrift git commit: THRIFT-4309: Python print() function Client: py

THRIFT-4309: Python print() function
Client: py

This closes #1339


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/4bd3682c
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/4bd3682c
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/4bd3682c

Branch: refs/heads/master
Commit: 4bd3682c79bcbd793f066bfab4d9bb1c1437b722
Parents: 9ce1fd9
Author: cclauss <cc...@bluewin.ch>
Authored: Fri Sep 1 17:40:29 2017 +0200
Committer: James E. King, III <jk...@apache.org>
Committed: Sun Sep 24 06:04:15 2017 -0700

----------------------------------------------------------------------
 .../fb303/py/fb303_scripts/fb303_simple_mgmt.py | 33 +++++++++-----------
 contrib/zeromq/test-client.py                   |  2 +-
 lib/nodejs/examples/httpServer.py               |  3 +-
 3 files changed, 17 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/4bd3682c/contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py
----------------------------------------------------------------------
diff --git a/contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py b/contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py
index 7d5d231..5c8f409 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
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/4bd3682c/contrib/zeromq/test-client.py
----------------------------------------------------------------------
diff --git a/contrib/zeromq/test-client.py b/contrib/zeromq/test-client.py
index 753b132..55c23e0 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__":

http://git-wip-us.apache.org/repos/asf/thrift/blob/4bd3682c/lib/nodejs/examples/httpServer.py
----------------------------------------------------------------------
diff --git a/lib/nodejs/examples/httpServer.py b/lib/nodejs/examples/httpServer.py
index b8ba586..b712fcd 100644
--- a/lib/nodejs/examples/httpServer.py
+++ b/lib/nodejs/examples/httpServer.py
@@ -7,7 +7,7 @@ from thrift.server import THttpServer
 
 class HelloSvcHandler:
   def hello_func(self):
-    print "Hello Called"
+    print("Hello Called")
     return "hello from Python"
 
 processor = HelloSvc.Processor(HelloSvcHandler())
@@ -16,4 +16,3 @@ port = 9090
 server = THttpServer.THttpServer(processor, ("localhost", port), protoFactory)
 print "Python server running on port " + str(port)
 server.serve()
-