This repository has been archived by the owner on Nov 2, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TMultiplexed{Service|Protocol} Proof of Concept
Fixes #102
- Loading branch information
Showing
12 changed files
with
665 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Autogenerated by Thrift Compiler (1.0.0-dev) | ||
# | ||
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING | ||
# | ||
# options string: py:new_style | ||
# | ||
|
||
import sys | ||
import pprint | ||
from urlparse import urlparse | ||
from thrift.transport import TTransport | ||
from thrift.transport import TSocket | ||
from thrift.transport import TSSLSocket | ||
from thrift.transport import THttpClient | ||
from thrift.protocol import TBinaryProtocol | ||
|
||
from sparts_examples import SpartsBarService | ||
from sparts_examples.ttypes import * | ||
|
||
epilog = """Functions: | ||
string bar() | ||
""" | ||
import argparse | ||
|
||
ap = argparse.ArgumentParser(epilog=epilog, | ||
formatter_class=argparse.RawTextHelpFormatter) | ||
ap.add_argument('-H', '--hostport', metavar='HOST[:PORT]') | ||
ap.add_argument('-u', '--url', metavar='URL') | ||
ap.add_argument('-f', '--framed', action='store_true') | ||
ap.add_argument('-s', '--ssl', action='store_true') | ||
ap.add_argument('-k', '--insecure', action='store_true') | ||
ap.add_argument('function') | ||
ap.add_argument('args', nargs='*') | ||
|
||
ns = ap.parse_args() | ||
|
||
pp = pprint.PrettyPrinter(indent = 2) | ||
host = 'localhost' | ||
port = 9090 | ||
uri = '' | ||
http = False | ||
argi = 1 | ||
|
||
if ns.hostport: | ||
parts = ns.hostport.split(':') | ||
host = parts[0] | ||
if len(parts) > 1: | ||
port = int(parts[1]) | ||
|
||
if ns.url: | ||
url = urlparse(ns.url) | ||
parts = url[1].split(':') | ||
host = parts[0] | ||
if len(parts) > 1: | ||
port = int(parts[1]) | ||
else: | ||
port = 80 | ||
uri = url[2] | ||
if url[4]: | ||
uri += '?%s' % url[4] | ||
http = True | ||
|
||
if http: | ||
transport = THttpClient.THttpClient(host, port, uri) | ||
else: | ||
if ns.ssl: | ||
check_ssl = not ns.insecure | ||
socket = TSSLSocket.TSSLSocket(host, port, | ||
not ns.insecure) | ||
else: | ||
socket = TSocket.TSocket(host, port) | ||
if ns.framed: | ||
transport = TTransport.TFramedTransport(socket) | ||
else: | ||
transport = TTransport.TBufferedTransport(socket) | ||
protocol = TBinaryProtocol.TBinaryProtocol(transport) | ||
client = SpartsBarService.Client(protocol) | ||
transport.open() | ||
|
||
if ns.function == 'bar': | ||
if len(ns.args) != 0: | ||
print 'bar requires 0 args' | ||
sys.exit(1) | ||
pp.pprint(client.bar()) | ||
|
||
else: | ||
print 'Unrecognized method %s' % ns.function | ||
sys.exit(1) | ||
|
||
transport.close() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.