[Blends-commit] [SCM] website branch, master, updated. 0e6e41dd792ced29ad7ab6a584b3b0747b254c28

Ole Streicher olebole at debian.org
Tue Mar 8 20:50:02 UTC 2016


The following commit has been merged in the master branch:
commit 0e6e41dd792ced29ad7ab6a584b3b0747b254c28
Author: Ole Streicher <olebole at debian.org>
Date:   Tue Mar 8 21:49:28 2016 +0100

    More PEP8 for thermometer.py

diff --git a/webtools/thermometer.py b/webtools/thermometer.py
index e96ae8a..d8c622b 100755
--- a/webtools/thermometer.py
+++ b/webtools/thermometer.py
@@ -2,11 +2,6 @@
 # Copyright 2013: Andreas Tille <tille at debian.org>
 # License: GPL
 
-#PORT=5441
-UDDPORT=5452
-PORT=UDDPORT
-DEFAULTPORT=5432
-
 from sys import argv, stderr, exit
 import codecs
 import os
@@ -24,10 +19,15 @@ from genshi.template.eval import UndefinedError
 
 from blendstasktools import ReadConfig, RowDictionaries, CheckOrCreateOutputDir, SetFilePermissions
 
+# PORT = 5441
+UDDPORT = 5452
+PORT = UDDPORT
+DEFAULTPORT = 5432
+
 ###########################################################################################
 # Define several prepared statements to query UDD
 try:
-    conn = psycopg2.connect(host="localhost",port=PORT,user="guest",database="udd")
+    conn = psycopg2.connect(host="localhost", port=PORT, user="guest", database="udd")
 except psycopg2.OperationalError, err:
     try:
         conn = psycopg2.connect("service=udd")
@@ -35,7 +35,8 @@ except psycopg2.OperationalError, err:
         # logger not known at this state: logger.warning
         stderr.write("Service=udd seems not to be installed on this host.\tMessage: %s\n" % (str(err)))
         try:
-            conn = psycopg2.connect(host="localhost",port=DEFAULTPORT,user="guest",database="udd")
+            conn = psycopg2.connect(host="localhost", port=DEFAULTPORT, user="guest",
+                                    database="udd")
         except psycopg2.OperationalError:
             # Hmmm, I observed a really strange behaviour on one of my
             # machines where connecting to localhost does not work but
@@ -47,6 +48,7 @@ except psycopg2.OperationalError, err:
 curs = conn.cursor()
 # uddlog = open('logs/uddquery.log', 'w')
 
+
 def _execute_udd_query(query):
     try:
         curs.execute(query)
@@ -253,7 +255,7 @@ def main():
         FROM new_packages np
         JOIN blends_dependencies b ON b.package = np.package
         -- make sure we get the right source version that does not necessarily match binary version
-        JOIN new_sources ns ON np.source = ns.source 
+        JOIN new_sources ns ON np.source = ns.source
         WHERE b.blend = $1 AND b.distribution = 'new'
         GROUP BY np.source
         ORDER BY np.source
@@ -325,17 +327,17 @@ def main():
       LEFT OUTER JOIN (SELECT source, upstream_version, status FROM upstream WHERE release = 'sid') d ON b.source = d.source
       ORDER BY b.source
     ;
-    """ % ( ubuntuprev2, ubuntuprev1, latestubuntu )
+    """ % (ubuntuprev2, ubuntuprev1, latestubuntu)
     _execute_udd_query(query)
-    
-    _execute_udd_query( "EXECUTE query_thermometer('%s')" % blendname)
-    
+
+    _execute_udd_query("EXECUTE query_thermometer('%s')" % blendname)
+
     if curs.rowcount > 0:
         blend_data = RowDictionaries(curs)
-        #f = open(blendname+'_thermometer.json', 'w')
-        #print >>f, json.dumps(blend_data)
-        #f.close()
-        #SetFilePermissions(blendname+'_thermometer.json')
+        # f = open(blendname+'_thermometer.json', 'w')
+        # print >>f, json.dumps(blend_data)
+        # f.close()
+        # SetFilePermissions(blendname+'_thermometer.json')
     else:
         stderr.write("No data received for Blend %s\n" % blendname)
         exit(1)
@@ -344,22 +346,22 @@ def main():
     current_dir  = os.path.dirname(__file__)
     # locale_dir   = os.path.join(current_dir, 'locale')
     template_dir = os.path.join(current_dir, 'templates')
-    
+
     # initialize gensi
     loader = TemplateLoader([template_dir], auto_reload=True,
                             default_encoding="utf-8")
-    
-    outputdir = CheckOrCreateOutputDir(config['outputdir'],'thermometer')
-    if outputdir == None:
+
+    outputdir = CheckOrCreateOutputDir(config['outputdir'], 'thermometer')
+    if outputdir is None:
         exit(-1)
-    
+
     t = datetime.now()
-    
+
     # Initialize i18n
     domain = 'blends-webtools'
     gettext.install(domain)
 
-    data={}
+    data = {}
     data['projectname'] = blendname
     data['blend_data']  = blend_data
     if config.get('advertising') != None:
@@ -387,7 +389,6 @@ def main():
     ulegend = legend[:]
     ulegend.remove(['new', 'Waiting in NEW'])
 
-
     data['ubuntuprev2']       = ubuntuprev2
     data['ubuntuprev1']       = ubuntuprev1
     data['latestubuntu']      = latestubuntu
@@ -396,14 +397,14 @@ def main():
     data['summary']           = _('Summary')
     data['idxsummary']        = _("""A %sDebian Pure Blend%s is a Debian internal project which assembles
 a set of packages that might help users to solve certain tasks of their work.  The list on
-the right shows the tasks of %s.""" ) \
+the right shows the tasks of %s.""") \
         % ('<a href="http://blends.alioth.debian.org/blends/">', '</a>', data['projectname'])
     data['idxsummary']        = Markup(data['idxsummary'])
 
     for key in ('homepage', 'projecturl', 'projectname', 'logourl', 'ubuntuhome', 'projectubuntu'):
         data[key] = config[key]
     data['updatetimestamp']   = _('Last update:') + ' ' + formatdate(time.mktime(t.timetuple()))
-                                                                  
+
     data['thermometer']  = blendname + '_thermometer.html'
     os.system("ln -sf %s %s/index.html" % (data['thermometer'], outputdir))
     data['uthermometer'] = 'ubuntu_' + blendname + '_thermometer.html'

-- 
Static and dynamic websites for Debian Pure Blends



More information about the Blends-commit mailing list