mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 15:00:30 +03:00
Some minor stats improvements
This commit is contained in:
parent
4cd263d598
commit
d1ad5bd74e
1 changed files with 58 additions and 42 deletions
|
|
@ -49,6 +49,8 @@ def main():
|
||||||
help="Spew out even more information than normal")
|
help="Spew out even more information than normal")
|
||||||
parser.add_option("-d", "--download", action="store_true", default=False,
|
parser.add_option("-d", "--download", action="store_true", default=False,
|
||||||
help="Download logs we don't have")
|
help="Download logs we don't have")
|
||||||
|
parser.add_option("--nologs", action="store_true", default=False,
|
||||||
|
help="Don't do anything logs-related")
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
|
|
@ -105,14 +107,16 @@ def main():
|
||||||
if ssh is not None:
|
if ssh is not None:
|
||||||
ssh.close()
|
ssh.close()
|
||||||
|
|
||||||
|
knownapks = common.KnownApks()
|
||||||
|
unknownapks = []
|
||||||
|
|
||||||
|
if not options.nologs:
|
||||||
# Process logs
|
# Process logs
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print 'Processing logs...'
|
print 'Processing logs...'
|
||||||
|
apps = {}
|
||||||
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
|
logsearch = re.compile(logexpr).search
|
||||||
apps = {}
|
|
||||||
unknownapks = []
|
|
||||||
knownapks = common.KnownApks()
|
|
||||||
for logfile in glob.glob(os.path.join(logsdir,'access-*.log.gz')):
|
for logfile in glob.glob(os.path.join(logsdir,'access-*.log.gz')):
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print '...' + logfile
|
print '...' + logfile
|
||||||
|
|
@ -150,6 +154,8 @@ def main():
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# Calculate and write stats for repo types...
|
# Calculate and write stats for repo types...
|
||||||
|
if options.verbose:
|
||||||
|
print "Processing repo types..."
|
||||||
repotypes = {}
|
repotypes = {}
|
||||||
for app in metaapps:
|
for app in metaapps:
|
||||||
if len(app['Repo Type']) == 0:
|
if len(app['Repo Type']) == 0:
|
||||||
|
|
@ -169,6 +175,8 @@ def main():
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# Calculate and write stats for update check modes...
|
# Calculate and write stats for update check modes...
|
||||||
|
if options.verbose:
|
||||||
|
print "Processing update check modes..."
|
||||||
ucms = {}
|
ucms = {}
|
||||||
for app in metaapps:
|
for app in metaapps:
|
||||||
checkmode = app['Update Check Mode'].split('/')[0]
|
checkmode = app['Update Check Mode'].split('/')[0]
|
||||||
|
|
@ -181,6 +189,8 @@ def main():
|
||||||
f.write(checkmode + ' ' + str(count) + '\n')
|
f.write(checkmode + ' ' + str(count) + '\n')
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
if options.verbose:
|
||||||
|
print "Processing categories..."
|
||||||
ctgs = {}
|
ctgs = {}
|
||||||
for app in metaapps:
|
for app in metaapps:
|
||||||
if app['Categories'] is None:
|
if app['Categories'] is None:
|
||||||
|
|
@ -196,6 +206,8 @@ def main():
|
||||||
f.write(category + ' ' + str(count) + '\n')
|
f.write(category + ' ' + str(count) + '\n')
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
if options.verbose:
|
||||||
|
print "Processing antifeatures..."
|
||||||
afs = {}
|
afs = {}
|
||||||
for app in metaapps:
|
for app in metaapps:
|
||||||
if app['AntiFeatures'] is None:
|
if app['AntiFeatures'] is None:
|
||||||
|
|
@ -212,6 +224,8 @@ def main():
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# Calculate and write stats for licenses...
|
# Calculate and write stats for licenses...
|
||||||
|
if options.verbose:
|
||||||
|
print "Processing licenses..."
|
||||||
licenses = {}
|
licenses = {}
|
||||||
for app in metaapps:
|
for app in metaapps:
|
||||||
license = app['License']
|
license = app['License']
|
||||||
|
|
@ -225,13 +239,15 @@ def main():
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# Write list of latest apps added to the repo...
|
# Write list of latest apps added to the repo...
|
||||||
|
if options.verbose:
|
||||||
|
print "Processing latest apps..."
|
||||||
latest = knownapks.getlatest(10)
|
latest = knownapks.getlatest(10)
|
||||||
f = open('stats/latestapps.txt', 'w')
|
f = open('stats/latestapps.txt', 'w')
|
||||||
for app in latest:
|
for app in latest:
|
||||||
f.write(app + '\n')
|
f.write(app + '\n')
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
if len(unknownapks) > 0:
|
if unknownapks:
|
||||||
print '\nUnknown apks:'
|
print '\nUnknown apks:'
|
||||||
for apk in unknownapks:
|
for apk in unknownapks:
|
||||||
print apk
|
print apk
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue