4 usage: %(progname)s [args] 8 import os, sys, string, time, getopt
11 roslib.load_manifest(
"webui")
14 from webui
import config
16 from pyclearsilver
import odb, hdfhelp, odb_sqlite3
17 from pyclearsilver
import CSPage
21 from pyclearsilver
import odb
22 from pyclearsilver
import hdfhelp
24 from launchman
import app
31 base, fn = os.path.split(path)
34 if os.path.exists(os.path.join(base,
"manifest.xml")):
35 base, package = os.path.split(base)
41 fn = apply(os.path.join, p)
43 return os.path.join(package, fn).replace(
".app",
"")
47 odb.Database.__init__(self, conn, debug=debug)
49 self.addTable(
"robots",
"ir_robots", RobotTable, rowClass=Robot)
50 self.addTable(
"apps",
"ir_apps", ApplicationTable, rowClass=Application)
51 self.addTable(
"appgroups",
"ir_app_groups", AppGroupTable, rowClass=AppGroup)
56 return hdfhelp.HdfItemList
63 self.d_addColumn(
"robotid", kInteger,primarykey=1, unique=1,
65 self.d_addColumn(
"name", kVarString)
70 class ApplicationTable(odb.Table):
72 self.d_addColumn(
"appid", kInteger,primarykey=1, unique=1,
74 self.d_addColumn(
"taskid", kVarString, unique=1)
77 appfn = os.path.abspath(appfn)
89 row = self.lookup(taskid=taskid)
93 rows = self.fetchAllRows()
98 _app = app.App(str(self.taskid))
99 doc = _app.load_yaml()
101 hdf.setValue(prefix +
"." +
"package", _app.package)
103 for key, val
in doc.items():
105 hdf.setValue(prefix +
"." + key, val)
107 hdf.setValue(prefix +
"." + key,
'')
112 self.d_addColumn(
"id", kVarString, primarykey=1, autoincrement=1)
113 self.d_addColumn(
"userid", kInteger)
114 self.d_addColumn(
"appids", kVarString)
115 self.d_addColumn(
"category", kVarString)
119 return self.appids.split(
',')
126 return os.path.join(path_to_store,
"webui.db3")
129 if timeout
is None: timeout = 600
131 path = config.getDBPath(
"webui")
134 config.createDBPath(path)
136 conn = odb_sqlite3.Connection(
fullDBPath(path),
143 db.synchronizeSchema()
147 if config.gWebUserID
is not None and config.gWebGroupID
is not None:
154 path = config.getDBPath(
"webui")
156 if os.path.exists(fn):
165 print __doc__ % vars()
167 def main(argv, stdout, environ):
169 optlist, args = getopt.getopt(argv[1:],
"", [
"help",
"test",
"debug"])
173 for (field, val)
in optlist:
174 if field ==
"--help":
177 elif field ==
"--debug":
179 elif field ==
"--test":
190 if __name__ ==
"__main__":
191 main(sys.argv, sys.stdout, os.environ)
def initSchema(create=0, timeout=None)
def fetchApp(self, prefix, hdf)
def defaultRowListClass(self)
def __init__(self, conn, debug=0)
def removeApp(self, taskid)
def defaultRowClass(self)
def installApp(self, taskid)
def main(argv, stdout, environ)
def installAppWithPath(self, appfn)
def fullDBPath(path_to_store)