Mercurial > hg > WSGraph
comparison wsgraph/client.py @ 27:9e173648d848
stubbing out client CLI
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 12 Dec 2012 18:54:59 -0800 |
parents | 60d7e38a20cd |
children |
comparison
equal
deleted
inserted
replaced
26:60d7e38a20cd | 27:9e173648d848 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 """REST API client for WSGraph""" | |
4 | |
5 import json | |
6 import sys | |
3 from model import Graph | 7 from model import Graph |
4 | 8 |
5 class WSGraphClient(): | 9 class WSGraphClient(Graph): |
6 """REST client for WSGraph""" | 10 """REST client for WSGraph""" |
7 | 11 |
8 def __init__(self, server): | 12 def __init__(self, server): |
9 self.server = server | 13 self.server = server |
10 | 14 |
15 def main(args=sys.argv[1:]): | |
16 """CLI interface for REST client for WSGraph""" | |
17 | |
18 # parse command line options | |
19 usage = """%prog [options] node [key1=value1] [key2=value2] [...] | |
20 %prog [options] node1 node2 [key1=value1] [key2=value2] [...]""" | |
21 parser = optparse.OptionParser(usage=usage, description=__doc__) | |
22 parser.add_option('-H', '--host', '--server', dest='server', | |
23 help="WSGraph server URL") | |
24 options, args = parser.parse_args(args) | |
25 | |
26 # sanity checks | |
27 if not options.server: | |
28 parser.error('-H/--server must be set') | |
29 | |
30 # instantiate model | |
31 graph = WSGraphClient(options.server) | |
32 | |
11 if __name__ == '__main__': | 33 if __name__ == '__main__': |
12 pass # TODO | 34 pass # TODO |