]> git.decadent.org.uk Git - dak.git/blobdiff - dak/show_new.py
Implement stats related to NEW processing
[dak.git] / dak / show_new.py
index b3420194de9c073002f06d836f4392461e97ee96..1397a324f6eae35d2fd8a5b5d105fda3a1a6bdb9 100755 (executable)
@@ -153,6 +153,8 @@ def html_footer():
 
 
 def do_pkg(upload_id):
+    cnf = Config()
+
     session = DBConn().session()
     upload = session.query(PolicyQueueUpload).filter_by(id=upload_id).one()
 
@@ -166,7 +168,7 @@ def do_pkg(upload_id):
     htmlfile = os.path.join(cnf['Show-New::HTMLPath'], htmlname)
 
     # Have we already processed this?
-    if False and os.path.exists(htmlfile) and \
+    if os.path.exists(htmlfile) and \
         os.stat(htmlfile).st_mtime > time.mktime(changes.created.timetuple()):
             with open(htmlfile, "r") as fd:
                 if fd.read() != timeout_str:
@@ -178,8 +180,10 @@ def do_pkg(upload_id):
     htmlfiles_to_process.append(htmlfile)
     sources.append(htmlname)
 
+    group = cnf.get('Dinstall::UnprivGroup') or None
+
     with open(htmlfile, 'w') as outfile:
-      with policy.UploadCopy(upload) as upload_copy:
+      with policy.UploadCopy(upload, group=group) as upload_copy:
         handler = policy.PolicyQueueUploadHandler(upload, session)
         missing = [ (o['type'], o['package']) for o in handler.missing_overrides() ]
         distribution = changes.distribution
@@ -219,7 +223,8 @@ def init(session):
     cnf = Config()
 
     Arguments = [('h',"help","Show-New::Options::Help"),
-                 ("p","html-path","Show-New::HTMLPath","HasArg")]
+                 ("p","html-path","Show-New::HTMLPath","HasArg"),
+                 ('q','queue','Show-New::Options::Queue','HasArg')]
 
     for i in ["help"]:
         if not cnf.has_key("Show-New::Options::%s" % (i)):
@@ -231,8 +236,9 @@ def init(session):
     if Options["help"]:
         usage()
 
+    queue_names = Options.find('Queue', 'new').split(',')
     uploads = session.query(PolicyQueueUpload) \
-        .join(PolicyQueueUpload.policy_queue).filter(PolicyQueue.queue_name == 'new') \
+        .join(PolicyQueueUpload.policy_queue).filter(PolicyQueue.queue_name.in_(queue_names)) \
         .join(PolicyQueueUpload.changes).order_by(DBChange.source)
 
     if len(changesnames) > 0:
@@ -245,17 +251,19 @@ def init(session):
 ################################################################################
 
 def main():
+    examine_package.use_html = True
+    pool = DakProcessPool(processes=5)
+
     session = DBConn().session()
     upload_ids = [ u.id for u in init(session) ]
     session.close()
 
-    examine_package.use_html=1
-
-    pool = DakProcessPool(processes=5)
-    p = pool.map_async(do_pkg, upload_ids)
+    for upload_id in upload_ids:
+        pool.apply_async(do_pkg, [upload_id])
     pool.close()
 
-    p.wait(timeout=600)
+    #p.wait(timeout=600)
+    pool.join()
     for htmlfile in htmlfiles_to_process:
         with open(htmlfile, "w") as fd:
             fd.write(timeout_str)