X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=tools%2Fdebianqueued-0.9%2Fshow-deferred;h=ab3fe5a3ef4a83189a0cb3cf6f07bc53079aeec1;hb=da551a812df331e3f18b392597db4bee3cba77cb;hp=9cb093d01b77bf75ecaee1453c6e0b70642f40dc;hpb=e3d86776388934031a347011c015b9198dea006d;p=dak.git
diff --git a/tools/debianqueued-0.9/show-deferred b/tools/debianqueued-0.9/show-deferred
index 9cb093d0..ab3fe5a3 100755
--- a/tools/debianqueued-0.9/show-deferred
+++ b/tools/debianqueued-0.9/show-deferred
@@ -21,11 +21,15 @@
################################################################################
import sys, os, re, time
+import apt_pkg
from debian_bundle import deb822
+from daklib import database
+from daklib import queue
+from daklib import utils
################################################################################
-row_number = 0
+row_number = 1
html_escaping = {'"':'"', '&':'&', '<':'<', '>':'>'}
re_html_escaping = re.compile('|'.join(map(re.escape, html_escaping.keys())))
@@ -94,12 +98,12 @@ def table_header():
return res
def table_footer():
- return '
\n'
+ return '
non-NEW uploads are available, use dcut reschedule foo.changes X-day to adjust delays.
\n'
def table_row(changesname, delay, changed_by, closes):
global row_number
- res = ''%(['even','odd'][row_number %2])
+ res = '
'%((row_number%2) and 'odd' or 'even')
res += (3*'%s | ')%tuple(map(html_escape,(changesname,delay,changed_by)))
res += ('%s | ' %
''.join(map(lambda close: '#%s
' % (close, close),closes)))
@@ -114,14 +118,33 @@ def get_upload_data(changesfn):
m = re.match(r'([0-9]+)-day', delay)
if m:
delaydays = int(m.group(1))
- remainingtime = max(0,24*60*60+os.stat(changesfn).st_mtime-time.time())
- delay = "%d days %02d:%02d" %(delaydays, int(remainingtime/3600),int(remainingtime/60)%60)
+ remainingtime = (delaydays>0)*max(0,24*60*60+os.stat(changesfn).st_mtime-time.time())
+ delay = "%d days %02d:%02d" %(max(delaydays-1,0), int(remainingtime/3600),int(remainingtime/60)%60)
else:
remainingtime = 0
#print dir(achanges)
- #print achanges.keys()
+ print >> sys.stderr, achanges.keys(), achanges['binary']
uploader = achanges.get('changed-by')
uploader = re.sub(r'^\s*(\S.*)\s+<.*>',r'\1',uploader)
+ if Cnf.has_key("Show-Deferred::LinkPath"):
+ isnew = 0
+ suites = database.get_suites(achanges['source'],src=1)
+ if 'unstable' not in suites and 'experimental' not in suites:
+ isnew = 1
+ for b in achanges['binary'].split():
+ suites = database.get_suites(b)
+ if 'unstable' not in suites and 'experimental' not in suites:
+ isnew = 1
+ if not isnew:
+ # we don't link .changes because we don't want other people to
+ # upload it with the existing signature.
+ for afn in map(lambda x: x['name'],achanges['files']):
+ lfn = os.path.join(Cnf["Show-Deferred::LinkPath"],afn)
+ qfn = os.path.join(os.path.dirname(changesfn),afn)
+ if os.path.islink(lfn):
+ os.unlink(lfn)
+ os.symlink(qfn,lfn)
+ os.chmod(qfn, 0644)
return (delaydays*24*60*60+remainingtime, changesname, delay, uploader, achanges.get('closes').split())
def list_uploads(filelist):
@@ -136,13 +159,50 @@ def list_uploads(filelist):
print 'Currently no deferred uploads to Debian
'
print footer()
-if len(sys.argv)!=2:
- print >> sys.stderr, """Error! Invoke %s /path/to/DEFERRED"""%sys.argv[0]
- sys.exit(1)
+def usage (exit_code=0):
+ if exit_code:
+ f = sys.stderr
+ else:
+ f = sys.stdout
+ print >> f, """Usage: dak show-deferred /path/to/DEFERRED
+ -h, --help show this help and exit.
+ -p, --html-path [path] override output directory.
+ """
+ sys.exit(exit_code)
+
+def init():
+ global Cnf, Options, Upload, projectB
+ Cnf = utils.get_conf()
+ Arguments = [('h',"help","Show-Deferred::Options::Help"),
+ ("p","link-path","Show-Deferred::LinkPath","HasArg")]
+ for i in ["help"]:
+ if not Cnf.has_key("Show-Deferred::Options::LinkPath"):
+ Cnf["Show-Deferred::Options::LinkPath"] = "/org/ftp.debian.org/web/deferred/"
+ if not Cnf.has_key("Show-Deferred::Options::%s" % (i)):
+ Cnf["Show-Deferred::Options::%s" % (i)] = ""
+ args = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
+ Options = Cnf.SubTree("Show-Deferred::Options")
+ if Options["help"]:
+ usage()
+ Upload = queue.Upload(Cnf)
+ projectB = Upload.projectB
+ return args
+
+args = init()
+if len(args)!=1:
+ usage(1)
filelist = []
-for r,d,f in os.walk(sys.argv[1]):
+for r,d,f in os.walk(args[0]):
filelist += map (lambda x: os.path.join(r,x),
filter(lambda x: x.endswith('.changes'), f))
-
list_uploads(filelist)
+
+if Cnf.has_key("Show-Deferred::LinkPath"):
+ # remove dead links
+ for r,d,f in os.walk(Cnf["Show-Deferred::LinkPath"]):
+ for af in f:
+ af = os.path.join(r,af)
+ if not os.path.exists(af):
+ print >> sys.stderr, "obsolete",af
+ os.unlink(af)