mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 15:00:30 +03:00
Remove the rest of the PEP8 errors from stats.py
This commit is contained in:
parent
5849b43e02
commit
bd34fc2530
1 changed files with 23 additions and 16 deletions
|
|
@ -28,10 +28,12 @@ from optparse import OptionParser
|
|||
import paramiko
|
||||
import socket
|
||||
import logging
|
||||
import common, metadata
|
||||
import common
|
||||
import metadata
|
||||
import subprocess
|
||||
from collections import Counter
|
||||
|
||||
|
||||
def carbon_send(key, value):
|
||||
s = socket.socket()
|
||||
s.connect((config['carbon_host'], config['carbon_port']))
|
||||
|
|
@ -42,6 +44,7 @@ def carbon_send(key, value):
|
|||
options = None
|
||||
config = None
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
global options, config
|
||||
|
|
@ -55,7 +58,8 @@ def main():
|
|||
parser.add_option("-d", "--download", action="store_true", default=False,
|
||||
help="Download logs we don't have")
|
||||
parser.add_option("--recalc", action="store_true", default=False,
|
||||
help="Recalculate aggregate stats - use when changes have been made that would invalidate old cached data.")
|
||||
help="Recalculate aggregate stats - use when changes "
|
||||
"have been made that would invalidate old cached data.")
|
||||
parser.add_option("--nologs", action="store_true", default=False,
|
||||
help="Don't do anything logs-related")
|
||||
(options, args) = parser.parse_args()
|
||||
|
|
@ -122,7 +126,9 @@ def main():
|
|||
logging.info('Processing logs...')
|
||||
appscount = Counter()
|
||||
appsvercount = Counter()
|
||||
logexpr = '(?P<ip>[.:0-9a-fA-F]+) - - \[(?P<time>.*?)\] "GET (?P<uri>.*?) HTTP/1.\d" (?P<statuscode>\d+) \d+ "(?P<referral>.*?)" "(?P<useragent>.*?)"'
|
||||
logexpr = '(?P<ip>[.:0-9a-fA-F]+) - - \[(?P<time>.*?)\] ' + \
|
||||
'"GET (?P<uri>.*?) HTTP/1.\d" (?P<statuscode>\d+) ' + \
|
||||
'\d+ "(?P<referral>.*?)" "(?P<useragent>.*?)"'
|
||||
logsearch = re.compile(logexpr).search
|
||||
for logfile in glob.glob(os.path.join(logsdir, 'access-*.log.gz')):
|
||||
logging.debug('...' + logfile)
|
||||
|
|
@ -160,7 +166,7 @@ def main():
|
|||
appver = apkname[:-4]
|
||||
today['appsver'][appver] += 1
|
||||
else:
|
||||
if not apkname in today['unknown']:
|
||||
if apkname not in today['unknown']:
|
||||
today['unknown'].append(apkname)
|
||||
|
||||
# Save calculated aggregate data for today to cache
|
||||
|
|
@ -173,7 +179,7 @@ def main():
|
|||
for appid in today['appsver']:
|
||||
appsvercount[appid] += today['appsver'][appid]
|
||||
for uk in today['unknown']:
|
||||
if not uk in unknownapks:
|
||||
if uk not in unknownapks:
|
||||
unknownapks.append(uk)
|
||||
|
||||
# Calculate and write stats for total downloads...
|
||||
|
|
@ -183,7 +189,8 @@ def main():
|
|||
count = appscount[appid]
|
||||
lst.append(appid + " " + str(count))
|
||||
if config['stats_to_carbon']:
|
||||
carbon_send('fdroid.download.' + appid.replace('.', '_'), count)
|
||||
carbon_send('fdroid.download.' + appid.replace('.', '_'),
|
||||
count)
|
||||
alldownloads += count
|
||||
lst.append("ALL " + str(alldownloads))
|
||||
f = open('stats/total_downloads_app.txt', 'w')
|
||||
|
|
@ -193,7 +200,8 @@ def main():
|
|||
f.close()
|
||||
|
||||
f = open('stats/total_downloads_app_version.txt', 'w')
|
||||
f.write('# Total downloads by application and version, since October 2011\n')
|
||||
f.write('# Total downloads by application and version, '
|
||||
'since October 2011\n')
|
||||
lst = []
|
||||
for appver in appsvercount:
|
||||
count = appsvercount[appver]
|
||||
|
|
@ -290,4 +298,3 @@ def main():
|
|||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue