1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!/usr/bin/python
from optparse import OptionParser
import os
import sys
sys.path.insert(0, os.path.dirname(__file__))
from udd import icommon
parser = OptionParser()
parser.add_option("--full", dest="full", action="store_true",
help="Also remove the revids: DANGEROUS")
parser.add_option("--force", dest="force", action="store_true",
help="Requeue even if it hasn't failed")
parser.add_option("--priority", dest="priority", action="store_true",
help="Requeue with a high priority")
parser.add_option("--auto", dest="auto", action="store_true",
help="Requeue this type of problem automatically from now on.")
parser.add_option("--all-of-type", dest="all", action="store_true",
help="Requeue all packages with this problem.")
opts, args = parser.parse_args()
errors = 0
if len(args) < 1:
print "Specify a list of packages to requeue"
sys.exit(1)
conn = icommon.get_sqlite_connection(icommon.sqlite_file)
db = icommon.StatusDatabase(icommon.sqlite_file)
for package in args:
lock = icommon.lock_package(package)
if lock is None:
print "Can't lock %s" % package
errors += 1
continue
retried = db.retry(package, force=opts.force, priority=opts.priority,
auto=opts.auto, all=opts.all)
if not retried:
print "%s has not failed" % package
errors += 1
continue
elif opts.full:
# FIXME: do this in one transaction somehow
c = conn.cursor()
try:
c.execute('delete from %s where package=?'
% icommon.RevidDatabase.REVID_TABLE, (package,))
c.execute(icommon.CommitDatabase.COMMIT_TABLE_DELETE, (package,))
c.execute(icommon.RevidDatabase.DELETE_WORKING, (package,))
conn.commit()
except:
conn.rollback()
raise
finally:
c.close()
lock.close()
if not opts.all:
print "%s requeued" % package
else:
print "%s and all similar requeued" % package
if errors > 0:
sys.exit(1)
|