sys.exit(1)
# Get all metadata-defined apps...
- metaapps = metadata.read_metadata()
+ metaapps = [a for a in metadata.read_metadata().itervalues() if not a['Disabled']]
statsdir = 'stats'
logsdir = os.path.join(statsdir, 'logs')
logging.info('Retrieving logs')
ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
- ssh.connect('f-droid.org', username='fdroid', timeout=10,
- key_filename=config['webserver_keyfile'])
+ ssh.connect(config['stats_server'], username=config['stats_user'],
+ timeout=10, key_filename=config['webserver_keyfile'])
ftp = ssh.open_sftp()
ftp.get_channel().settimeout(60)
logging.info("...connected")
'apps': Counter(),
'appsver': Counter(),
'unknown': []
- }
+ }
p = subprocess.Popen(["zcat", logfile], stdout=subprocess.PIPE)
matches = (logsearch(line) for line in p.stdout)
for match in matches:
- if match and match.group('statuscode') == '200':
- uri = match.group('uri')
- if uri.endswith('.apk'):
- _, apkname = os.path.split(uri)
- app = knownapks.getapp(apkname)
- if app:
- appid, _ = app
- today['apps'][appid] += 1
- # Strip the '.apk' from apkname
- appver = apkname[:-4]
- today['appsver'][appver] += 1
- else:
- if apkname not in today['unknown']:
- today['unknown'].append(apkname)
+ if not match:
+ continue
+ if match.group('statuscode') != '200':
+ continue
+ if match.group('ip') in config['stats_ignore']:
+ continue
+ uri = match.group('uri')
+ if not uri.endswith('.apk'):
+ continue
+ _, apkname = os.path.split(uri)
+ app = knownapks.getapp(apkname)
+ if app:
+ appid, _ = app
+ today['apps'][appid] += 1
+ # Strip the '.apk' from apkname
+ appver = apkname[:-4]
+ today['appsver'][appver] += 1
+ else:
+ if apkname not in today['unknown']:
+ today['unknown'].append(apkname)
# Save calculated aggregate data for today to cache
with open(agg_path, 'w') as f:
logging.info("Processing repo types...")
repotypes = Counter()
for app in metaapps:
- if len(app['Repo Type']) == 0:
- rtype = 'none'
- else:
- if app['Repo Type'] == 'srclib':
- rtype = common.getsrclibvcs(app['Repo'])
- else:
- rtype = app['Repo Type']
+ rtype = app['Repo Type'] or 'none'
+ if rtype == 'srclib':
+ rtype = common.getsrclibvcs(app['Repo'])
repotypes[rtype] += 1
f = open('stats/repotypes.txt', 'w')
for rtype in repotypes: