4 usage: %(progname)s [args] 8 import os, sys, string, time, getopt
14 from pyclearsilver
import odb, hdfhelp, odb_sqlite3
15 from pyclearsilver
import CSPage
21 gDBTablePrefix =
"queue" 25 odb.Database.__init__(self, conn, debug=debug)
27 self.addTable(
"queue", gDBTablePrefix +
"_queue", QueueTable,
28 rowClass=CommandRecord)
33 return hdfhelp.HdfItemList
37 self.d_addColumn(
"qid",kInteger,
None,primarykey = 1,
40 self.d_addColumn(
"username",kVarString)
41 self.d_addColumn(
"cmd",kVarString, indexed=1)
42 self.d_addColumn(
"data",kVarString)
43 self.d_addColumn(
"startDate", kInteger, default=0)
48 rows = self.fetchRows((
'cmd', cmd), where=
"startDate <= %s" % when)
50 rows = self.fetchRows((
'cmd', cmd))
55 row.username = username
56 row.startDate = startDate
68 return os.path.join(path_to_store, gDBFilename +
".db3")
71 if timeout
is None: timeout = 600
73 path = config.getSiteDBPath(
"host")
76 config.createDBPath(path)
78 conn = odb_sqlite3.Connection(
fullDBPath(path),
86 db.synchronizeSchema()
89 if config.gWebUserID
is not None and config.gWebGroupID
is not None:
95 path = config.getSiteDBPath(
"host")
97 if os.path.exists(fn):
110 rows = db.queue.fetchAllRows()
112 print row.username, row.cmd, row.data
116 print __doc__ % vars()
118 def main(argv, stdout, environ):
120 optlist, args = getopt.getopt(argv[1:],
"", [
"help",
"test",
"debug"])
123 for (field, val)
in optlist:
124 if field ==
"--help":
127 elif field ==
"--debug":
129 elif field ==
"--test":
140 if __name__ ==
"__main__":
141 main(sys.argv, sys.stdout, os.environ)
def fullDBPath(path_to_store)
def defaultRowListClass(self)
def initSchema(create=0, timeout=None)
def defaultRowClass(self)
def __init__(self, conn, debug=0)
def getCommands(self, cmd, when=None)
def main(argv, stdout, environ)
def newCommand(self, username, cmd, startDate, data="")