]> git.decadent.org.uk Git - dak.git/blobdiff - dak/show_new.py
Merge remote-tracking branch 'nthykier/auto-decruft'
[dak.git] / dak / show_new.py
index b3420194de9c073002f06d836f4392461e97ee96..64ea22874d0d36096e86f9b1c77c43444ce2bacd 100755 (executable)
@@ -62,7 +62,7 @@ def html_header(name, missing):
     />
     <title>%(name)s - Debian NEW package overview</title>
     <link type="text/css" rel="stylesheet" href="/style.css" />
-    <link rel="shortcut icon" href="http://www.debian.org/favicon.ico" />
+    <link rel="shortcut icon" href="https://www.debian.org/favicon.ico" />
     <script type="text/javascript">
       //<![CDATA[
       <!--
@@ -89,21 +89,21 @@ def html_header(name, missing):
   </head>
   <body id="NEW-details-page">
     <div id="logo">
-      <a href="http://www.debian.org/">
-        <img src="http://www.debian.org/logos/openlogo-nd-50.png"
+      <a href="https://www.debian.org/">
+        <img src="https://www.debian.org/logos/openlogo-nd-50.png"
         alt="debian logo" /></a>
-      <a href="http://www.debian.org/">
-        <img src="http://www.debian.org/Pics/debian.png"
+      <a href="https://www.debian.org/">
+        <img src="https://www.debian.org/Pics/debian.png"
         alt="Debian Project" /></a>
     </div>
     <div id="titleblock">
-      <img src="http://www.debian.org/Pics/red-upperleft.png"
+      <img src="https://www.debian.org/Pics/red-upperleft.png"
       id="red-upperleft" alt="corner image"/>
-      <img src="http://www.debian.org/Pics/red-lowerleft.png"
+      <img src="https://www.debian.org/Pics/red-lowerleft.png"
       id="red-lowerleft" alt="corner image"/>
-      <img src="http://www.debian.org/Pics/red-upperright.png"
+      <img src="https://www.debian.org/Pics/red-upperright.png"
       id="red-upperright" alt="corner image"/>
-      <img src="http://www.debian.org/Pics/red-lowerright.png"
+      <img src="https://www.debian.org/Pics/red-lowerright.png"
       id="red-lowerright" alt="corner image"/>
       <span class="title">
         Debian NEW package overview for %(name)s
@@ -137,22 +137,15 @@ def html_header(name, missing):
 def html_footer():
     result = """    <p class="validate">Timestamp: %s (UTC)</p>
 """% (time.strftime("%d.%m.%Y / %H:%M:%S", time.gmtime()))
-    result += """    <p><a href="http://validator.w3.org/check?uri=referer">
-      <img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"
-      style="border: none; height: 31px; width: 88px" /></a>
-    <a href="http://jigsaw.w3.org/css-validator/check/referer">
-      <img src="http://jigsaw.w3.org/css-validator/images/vcss"
-      alt="Valid CSS!" style="border: none; height: 31px; width: 88px" /></a>
-    </p>
-  </body>
-</html>
-"""
+    result += "</body></html>"
     return result
 
 ################################################################################
 
 
 def do_pkg(upload_id):
+    cnf = Config()
+
     session = DBConn().session()
     upload = session.query(PolicyQueueUpload).filter_by(id=upload_id).one()
 
@@ -166,7 +159,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 +171,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 +214,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 +227,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 +242,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)