community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject svn commit: r1839311 - /comdev/project-logos/tools/poweredby.py
Date Mon, 27 Aug 2018 12:58:38 GMT
Author: humbedooh
Date: Mon Aug 27 12:58:38 2018
New Revision: 1839311

URL: http://svn.apache.org/viewvc?rev=1839311&view=rev
Log:
only update new images

Modified:
    comdev/project-logos/tools/poweredby.py

Modified: comdev/project-logos/tools/poweredby.py
URL: http://svn.apache.org/viewvc/comdev/project-logos/tools/poweredby.py?rev=1839311&r1=1839310&r2=1839311&view=diff
==============================================================================
--- comdev/project-logos/tools/poweredby.py (original)
+++ comdev/project-logos/tools/poweredby.py Mon Aug 27 12:58:38 2018
@@ -17,26 +17,32 @@ pb_dir = '/var/www/logos/site/poweredby'
 projects = [x for x in os.listdir(res_dir) if os.path.isdir(os.path.join(res_dir, x))]
 
 for project in sorted(projects):
-    if os.path.exists('%s/%s/default_hr.png' % (res_dir, project)):
-        back = Image.open(pb_image)
-        front = Image.open('%s/%s/default_hr.png' % (res_dir, project))
-        
-        w = front.width
-        h = front.height
-        to_edge = math.sqrt(((w/2)*(w/2)) + ((h/2)*(h/2)))
-        while to_edge > 472:
-            w *= 0.995
-            h *= 0.995
+    dpath = '%s/%s/default_hr.png' % (res_dir, project)
+    if os.path.exists(dpath):
+        try:
+          st = os.stat(dpath)
+        except:
+          st = None
+        if (not st) or st.st_mtime > (time.time() - 43200):
+            back = Image.open(pb_image)
+            front = Image.open('%s/%s/default_hr.png' % (res_dir, project))
+            
+            w = front.width
+            h = front.height
             to_edge = math.sqrt(((w/2)*(w/2)) + ((h/2)*(h/2)))
-        w = int(w)
-        h = int(h)
-        print("Generating 'Powered By' for %s (%u x %u)..." % (project, w, h))
-        size = (w, h)
-        front.thumbnail(size, Image.ANTIALIAS)
-        
-        centerx = int((back.width/2) - (w/2))
-        centery = int((back.height/2) - (h/2))
-        back.paste(front, (centerx, centery), front)
-        
-        back.save('%s/%s.png' % (pb_dir, project), 'PNG')
-        
\ No newline at end of file
+            while to_edge > 472:
+                w *= 0.995
+                h *= 0.995
+                to_edge = math.sqrt(((w/2)*(w/2)) + ((h/2)*(h/2)))
+            w = int(w)
+            h = int(h)
+            print("Generating 'Powered By' for %s (%u x %u)..." % (project, w, h))
+            size = (w, h)
+            front.thumbnail(size, Image.ANTIALIAS)
+            
+            centerx = int((back.width/2) - (w/2))
+            centery = int((back.height/2) - (h/2))
+            back.paste(front, (centerx, centery), front)
+            
+            back.save('%s/%s.png' % (pb_dir, project), 'PNG')
+            
\ No newline at end of file



Mime
View raw message