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.
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1179905 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc
index 53c190a..1a75fd8 100644
--- a/compiler/cpp/src/generate/t_py_generator.cc
+++ b/compiler/cpp/src/generate/t_py_generator.cc
@@ -1430,7 +1430,7 @@
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 @@
"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 <<