From 27a07d7063fd8406b9f98084697063e818e1086b Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Fri, 31 Aug 2012 18:17:38 +0100 Subject: [PATCH] Stats-related things must be explicitly enabled (issue #51) --- config.sample.py | 5 +++++ fdroidserver/stats.py | 6 ++++++ fdroidserver/update.py | 38 +++++++++++++++++++++----------------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/config.sample.py b/config.sample.py index a3c3da04..3d652cbd 100644 --- a/config.sample.py +++ b/config.sample.py @@ -49,3 +49,8 @@ wiki_path = "/wiki/" wiki_user = "login" wiki_password = "1234" +#Only set this to true when running a repository where you want to generate +#stats, and only then on the master build servers, not a development +#machine. +update_stats = False + diff --git a/fdroidserver/stats.py b/fdroidserver/stats.py index e191f538..c4b4e693 100644 --- a/fdroidserver/stats.py +++ b/fdroidserver/stats.py @@ -33,8 +33,14 @@ import common def main(): # Read configuration... + global update_stats + update_stats = False execfile('config.py', globals()) + if not update_stats: + print "Stats are disabled - check your configuration" + sys.exit(1) + # Parse command line... parser = OptionParser() parser.add_option("-v", "--verbose", action="store_true", default=False, diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 7654c908..16c3bd80 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -170,6 +170,8 @@ def update_wiki(apps, apks, verbose=False): def main(): # Read configuration... + global update_stats + update_stats = False execfile('config.py', globals()) # Parse command line... @@ -650,24 +652,26 @@ def main(): f.write(catdata) f.close() - # Update known apks info... - knownapks.writeifchanged() + if update_stats: - # Generate latest apps data for widget - if os.path.exists(os.path.join('stats', 'latestapps.txt')): - data = '' - for line in file(os.path.join('stats', 'latestapps.txt')): - appid = line.rstrip() - data += appid + "\t" - for app in apps: - if app['id'] == appid: - data += app['Name'] + "\t" - data += app['icon'] + "\t" - data += app['License'] + "\n" - break - f = open('repo/latestapps.dat', 'w') - f.write(data) - f.close() + # Update known apks info... + knownapks.writeifchanged() + + # Generate latest apps data for widget + if os.path.exists(os.path.join('stats', 'latestapps.txt')): + data = '' + for line in file(os.path.join('stats', 'latestapps.txt')): + appid = line.rstrip() + data += appid + "\t" + for app in apps: + if app['id'] == appid: + data += app['Name'] + "\t" + data += app['icon'] + "\t" + data += app['License'] + "\n" + break + f = open('repo/latestapps.dat', 'w') + f.write(data) + f.close() # Update the wiki... if options.wiki: