4 # Tangible Bit text mode client
5 # by Smári McCarthy <smari@fabfolk.com>
8 # Cache settings for some period between executions if running standalone
9 # See TODO lists in functions.
16 configfiles
= ["tbdefaults.conf", "~/.tangiblebit/tb.conf"]
17 settings
= ConfigParser
.ConfigParser()
20 # Load settings. RFC 822.
22 for cfg
in configfiles
:
23 cfgs
.append(os
.path
.abspath(os
.path
.expanduser(cfg
)))
29 # if username and password are set in settings, use the Authenticated XMLRPC module...
30 # if settings["ssl"] == True, use the SSL interface
31 return xmlrpclib
.Server(settings
.get("server", "xmlrpcpath"))
34 print("tb-get - Tangible Bit text mode client")
35 print("------------------------------------------------------")
36 print("help - get help")
37 print("fetch - download object definition")
38 print("sites - get a list of sites")
39 print("materials - get a list of properties")
40 print("order - put in an order for an object")
41 print("login - log in to Tangible Bit server")
45 print("Provide a username and password to log in.")
46 print("You can also specify these in the config file (%s) to log in automagically" % settings
["configfile"])
48 settings
.set("server", "username", args
[0])
49 settings
.set("server", "password", args
[1])
52 # TODO: Perhaps this should check if they're actually valid?
53 return settings
.has_option("server", "username") and settings
.has_option("server", "password")
56 # TODO: Fetching functionality...
57 # - GetObject not implemented on the XMLRPC
58 # - objects recieved need to be unpacked and put into a folder with appropriate files
61 object = conn
.GetObject(objectname
)
64 # TODO: Search functions that make sense for looking up sites
65 # - Get a list of sites
66 # - Get details for a certain site
67 # - Get sites within a certain radius of a certain location
68 # - What orders are currently being processed at a site
69 # - What is the access model of a certain site
70 # - What sites are within a certain region
74 # TODO: Search functions that make sense for looking up materials
75 # - which materials fulfil a certain set of properties
76 # - which objects use a certain material
77 # - which materials are available within a certain radius of a certain location
78 # - which materials are available within a certain region
79 # - which materials exist in a certain inventory
80 # - compare two or more materials
84 # TODO: Appropriate ordering functions
85 # - Place order (interactive?)
86 # - Set shipping destination
87 # - Change where to order from (only possible if order hasn't been processed)
88 # - Compare object prices between sites (if applicable)
90 print("E: You must log in to place orders.")
100 if __name__
== "__main__":
101 if len(sys
.argv
) < 2:
106 if action
== "help": Help(sys
.argv
[2:])
107 elif action
== "fetch": Fetch(sys
.argv
[2:])
108 elif action
== "login": Login(sys
.argv
[2:])
109 elif action
== "sites": Sites(sys
.argv
[2:])
110 elif action
== "materials": Materials(sys
.argv
[2:])
111 elif action
== "order": Order(sys
.argv
[2:])
113 print("E: Unknown action. Try 'help'.")