You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jf...@apache.org on 2011/10/07 02:14:36 UTC

svn commit: r1179905 - /thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc

Author: jfarrell
Date: Fri Oct  7 00:14:34 2011
New Revision: 1179905

URL: http://svn.apache.org/viewvc?rev=1179905&view=rev
Log:
Thrift-1376: Make port specification option in thrift remote
Client: py
Patch: Dave Watson

The thrift-generated Python service client allows overriding the default host/port by doing "-h host:port" on the command line. Oftentimes, you want to override the host but not the port, as most services run on well-defined ports.


Modified:
    thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc

Modified: thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc
URL: http://svn.apache.org/viewvc/thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc?rev=1179905&r1=1179904&r2=1179905&view=diff
==============================================================================
--- thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc (original)
+++ thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc Fri Oct  7 00:14:34 2011
@@ -1430,7 +1430,7 @@ void t_py_generator::generate_service_re
   f_remote <<
     "if len(sys.argv) <= 1 or sys.argv[1] == '--help':" << endl <<
     "  print ''" << endl <<
-    "  print 'Usage: ' + sys.argv[0] + ' [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]'" << endl <<
+    "  print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]'" << endl <<
     "  print ''" << endl <<
     "  print 'Functions:'" << endl;
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -1469,7 +1469,8 @@ void t_py_generator::generate_service_re
     "if sys.argv[argi] == '-h':" << endl <<
     "  parts = sys.argv[argi+1].split(':')" << endl <<
     "  host = parts[0]" << endl <<
-    "  port = int(parts[1])" << endl <<
+    "  if len(parts) > 1:" << endl <<
+    "    port = int(parts[1])" << endl <<
     "  argi += 2" << endl <<
     endl <<
     "if sys.argv[argi] == '-u':" << endl <<