28 """!Marks all tasks as not having failed.
29 @param ds the produtil.datastore.Datastore to modify."""
30 with ds.transaction()
as t:
31 t.mutate(
"""UPDATE products SET available=?
32 WHERE id LIKE '%s%%' AND
33 NOT available=?"""%(TASK_CATEGORY),
34 (UNSTARTED,COMPLETED))
37 """!Marks all products as unavailable and tasks as unstarted.
38 @param ds the produtil.datastore.Datastore to modify."""
39 with ds.transaction()
as t:
40 t.mutate(
"UPDATE products SET available=?",(UNSTARTED,))
42 def unrun_one(ds,did):
43 """!Marks a specific task as unstarted.
44 @param ds the produtil.datastore.Datastore to modify.
45 @param did the taskname"""
46 with ds.transaction()
as t:
47 taskid=
"%s::%s"%(TASK_CATEGORY,str(did))
48 print>>sys.stderr,
'Marking %s as unstarted.'%(taskid,)
49 t.mutate(
"UPDATE products SET available=? WHERE id=?",
53 """!Dumps the contents of the given Datastore to stdout
54 @param ds the produtil.datastore.Datastore to dump"""
58 """!Sends a program usage message to stderr and exits with status 2
59 @param args the command-line arguments that were provided."""
60 print>>sys.stderr,
'''FORMAT: hwrf_datastore.py OP [ARG] file1.sqlite3 [file2.sqlite3 [...]]
62 DUMP - dump entire database to stdout
63 UNFAIL - mark all failed or running tasks as unstarted
64 UNRUN - mark all tasks as unstarted
66 Only UNRUN_ONE takes an argument, and that argument is mandatory: the
67 task to "unrun". The argument is the task id, which is everything in
68 the id after the %s:: in the output of ab hwrf_datastore.py DUMP.
75 """!Main program. Parses arguments and calls other functions in
76 this program to do the real work."""
77 if len(sys.argv)<3: usage()
82 if sys.argv[1].upper()==
'UNFAIL': op=unfail
83 elif sys.argv[1].upper()==
'DUMP': op=dump
84 elif sys.argv[1].upper()==
'UNRUN': op=unrun
85 elif sys.argv[1].upper()==
'UNRUN_ONE':
90 usage(
'Unrecognized datastore operation %s'%(sys.argv[1],))
92 if len(sys.argv)<first_arg+1: usage()
94 if op
is dump: readonly=
True
96 logging.basicConfig(stream=sys.stderr,level=logging.INFO)
97 for filename
in sys.argv[first_arg:]:
98 ds=Datastore(filename,logger=logging.getLogger(),locking=
not readonly)
99 with ds.transaction()
as t:
102 if __name__==
'__main__': main()
Stores products and tasks in an sqlite3 database file.