From 7878d959e7cec999182ce8e49e9c9d3aa4cb5440 Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Fri, 31 May 2013 07:51:54 +0100 Subject: [PATCH] Improve the stats bandwidth/diskspace/memory situation a bit --- fdroidserver/stats.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/fdroidserver/stats.py b/fdroidserver/stats.py index 50c82055..d71b14a1 100644 --- a/fdroidserver/stats.py +++ b/fdroidserver/stats.py @@ -30,7 +30,7 @@ import HTMLParser import paramiko import common import socket - +import subprocess def carbon_send(key, value): s = socket.socket() @@ -90,21 +90,14 @@ def main(): ftp.chdir('logs') files = ftp.listdir() for f in files: - if f.startswith('access-') and f.endswith('.log'): + if f.startswith('access-') and f.endswith('.log.gz'): destpath = os.path.join(logsdir, f) - archivepath = os.path.join(logsarchivedir, f + '.gz') - if os.path.exists(archivepath): - if os.path.exists(destpath): - # Just in case we have it archived but failed to remove - # the original... - os.remove(destpath) - else: - destsize = ftp.stat(f).st_size - if (not os.path.exists(destpath) or - os.path.getsize(destpath) != destsize): - print "...retrieving " + f - ftp.get(f, destpath) + destsize = ftp.stat(f).st_size + if (not os.path.exists(destpath) or + os.path.getsize(destpath) != destsize): + print "...retrieving " + f + ftp.get(f, destpath) except Exception as e: traceback.print_exc() sys.exit(1) @@ -116,14 +109,19 @@ def main(): ssh.close() # Process logs + if options.verbose: + print 'Processing logs...' logexpr = '(?P[.:0-9a-fA-F]+) - - \[(?P