chiark / gitweb /
Tracking of dates apks are added to the repo
authorCiaran Gultnieks <ciaran@ciarang.com>
Thu, 19 Jan 2012 23:03:35 +0000 (23:03 +0000)
committerCiaran Gultnieks <ciaran@ciarang.com>
Thu, 19 Jan 2012 23:03:35 +0000 (23:03 +0000)
common.py
updatestats.py

index e050884e482a2a6b9d18250c0831661dda03a01e..8070373c43ec82d3adb9d0971f76369c87d9087f 100644 (file)
--- a/common.py
+++ b/common.py
@@ -19,7 +19,7 @@
 import glob, os, sys, re
 import shutil
 import subprocess
-
+import time
 
 def getvcs(vcstype, remote, local):
     if vcstype == 'git':
@@ -791,7 +791,10 @@ class KnownApks:
         if os.path.exists(self.path):
             for line in file( self.path):
                 t = line.rstrip().split(' ')
-                self.apks[t[0]] = t[1]
+                if len(t) == 2:
+                    self.apks[t[0]] = (t[1], None)
+                else:
+                    self.apks[t[0]] = (t[1], time.strptime(t[2], '%Y-%m-%d'))
         self.changed = False
 
     def writeifchanged(self):
@@ -801,14 +804,18 @@ class KnownApks:
             f = open(self.path, 'w')
             lst = []
             for apk, app in self.apks.iteritems():
-                lst.append(apk + ' ' + app)
+                appid, added = app
+                line = apk + ' ' + appid
+                if added:
+                    line += ' ' + time.strftime('%Y-%m-%d', added)
+                lst.append(line)
             for line in sorted(lst):
                 f.write(line + '\n')
             f.close()
 
     def recordapk(self, apk, app):
         if not apk in self.apks:
-            self.apks[apk] = app
+            self.apks[apk] = (app, time.gmtime(time.time()))
             self.changed = True
 
     def getapp(self, apkname):
index 61dd6412bc30296f2173247c78d6aea346f47849..068c0b6d8475e3d21c5c3429314f784d4aa6cbfd 100755 (executable)
@@ -112,10 +112,11 @@ for logfile in glob.glob(os.path.join(logsdir,'access-*.log')):
                 _, apkname = os.path.split(uri)
                 app = knownapks.getapp(apkname)
                 if app:
-                    if app in apps:
-                        apps[app] += 1
+                    appid, _ = app
+                    if appid in apps:
+                        apps[appid] += 1
                     else:
-                        apps[app] = 1
+                        apps[appid] = 1
                 else:
                     if not apkname in unknownapks:
                         unknownapks.append(apkname)