Mercurial > hg > WSGraph
annotate wsgraph/client.py @ 46:2d57cda87036
start noting useful graph DBs
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Tue, 16 Apr 2013 01:03:19 -0700 (2013-04-16) |
| parents | 9e173648d848 |
| children |
| rev | line source |
|---|---|
|
24
e46b4466abac
start a RESTful client; putting this here for now; it could go in model.py as it will inherit from the ABC, but keeping it here avoids a ccertain class of import hell
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
|
e46b4466abac
start a RESTful client; putting this here for now; it could go in model.py as it will inherit from the ABC, but keeping it here avoids a ccertain class of import hell
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
2 |
| 27 | 3 """REST API client for WSGraph""" |
| 4 | |
| 5 import json | |
| 6 import sys | |
| 26 | 7 from model import Graph |
|
24
e46b4466abac
start a RESTful client; putting this here for now; it could go in model.py as it will inherit from the ABC, but keeping it here avoids a ccertain class of import hell
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 |
| 27 | 9 class WSGraphClient(Graph): |
|
24
e46b4466abac
start a RESTful client; putting this here for now; it could go in model.py as it will inherit from the ABC, but keeping it here avoids a ccertain class of import hell
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
10 """REST client for WSGraph""" |
|
e46b4466abac
start a RESTful client; putting this here for now; it could go in model.py as it will inherit from the ABC, but keeping it here avoids a ccertain class of import hell
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 |
|
e46b4466abac
start a RESTful client; putting this here for now; it could go in model.py as it will inherit from the ABC, but keeping it here avoids a ccertain class of import hell
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 def __init__(self, server): |
|
e46b4466abac
start a RESTful client; putting this here for now; it could go in model.py as it will inherit from the ABC, but keeping it here avoids a ccertain class of import hell
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
13 self.server = server |
|
e46b4466abac
start a RESTful client; putting this here for now; it could go in model.py as it will inherit from the ABC, but keeping it here avoids a ccertain class of import hell
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
14 |
| 27 | 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 | |
|
24
e46b4466abac
start a RESTful client; putting this here for now; it could go in model.py as it will inherit from the ABC, but keeping it here avoids a ccertain class of import hell
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
33 if __name__ == '__main__': |
|
e46b4466abac
start a RESTful client; putting this here for now; it could go in model.py as it will inherit from the ABC, but keeping it here avoids a ccertain class of import hell
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
34 pass # TODO |
