From b5d94e07c481bacb0de55dfc9c16b2cf86feb25c Mon Sep 17 00:00:00 2001 From: Jake Farrell Date: Fri, 7 Oct 2011 00:14:34 +0000 Subject: [PATCH] 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 --- compiler/cpp/src/generate/t_py_generator.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc index 53c190ab..1a75fd81 100644 --- a/compiler/cpp/src/generate/t_py_generator.cc +++ b/compiler/cpp/src/generate/t_py_generator.cc @@ -1430,7 +1430,7 @@ void t_py_generator::generate_service_remote(t_service* tservice) { 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_remote(t_service* tservice) { "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 << -- 2.17.1