diff --git a/common.py b/common.py index e050884e..8070373c 100644 --- 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): diff --git a/updatestats.py b/updatestats.py index 61dd6412..068c0b6d 100755 --- a/updatestats.py +++ b/updatestats.py @@ -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)