[game-data-packager] 01/01: publish popcon snasphoting + parsing scripts
Alexandre Detiste
detiste-guest at moszumanska.debian.org
Sun Mar 6 14:36:38 UTC 2016
This is an automated email from the git hooks/post-receive script.
detiste-guest pushed a commit to branch master
in repository game-data-packager.
commit 42a8b531ec31870eceb9049c52a0b9ae870831fe
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date: Sun Mar 6 15:36:06 2016 +0100
publish popcon snasphoting + parsing scripts
---
tools/popcon.py | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tools/popcon.sh | 22 ++++++++++++++++
2 files changed, 104 insertions(+)
diff --git a/tools/popcon.py b/tools/popcon.py
new file mode 100755
index 0000000..4973fdf
--- /dev/null
+++ b/tools/popcon.py
@@ -0,0 +1,82 @@
+#!/usr/bin/python3
+# encoding=utf-8
+#
+# Copyright © 2016 Alexandre Detiste <alexandre at detiste.be>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# You can find the GPL license text on a Debian system under
+# /usr/share/common-licenses/GPL-2.
+
+import glob
+import gzip
+import sys
+
+scope = set()
+with open('out/bash_completion', 'r') as bash:
+ # keep each even line
+ while bash.readline():
+ scope |= set(bash.readline().rstrip().split())
+
+# old package names
+scope.add('quake2-data')
+scope.add('wolf3d-data-wl1')
+scope.add('wolf3d-v14-data')
+scope.add('rtcw-data')
+
+# add this to compare against other Doom packages
+scope.add('doom-wad-shareware')
+
+scope.add('game-data-packager')
+
+def process(scope, distro):
+ result = dict()
+ if len(sys.argv) == 2:
+ popcon = '/var/cache/popcon/' + distro + '_' + sys.argv[1] + '.gz'
+ else:
+ popcon = sorted(glob.glob('/var/cache/popcon/' + distro + '_*.gz')).pop()
+
+ with gzip.open(popcon, 'rb') as f:
+ file_content = f.read().decode('latin1')
+ for line in file_content.split('\n'):
+ if not line or line[0] in ('#','-'):
+ continue
+ try:
+ package, score = line.split()[1:3]
+ score = int(score)
+ if package in scope:
+ #print("%30s %d" % (package, score))
+ result[package] = score
+ # theres is some random crap with 0 popcon in the Ubuntu file
+ except ValueError:
+ #print(distro,line)
+ pass
+
+ return result
+
+debian = process(scope, 'debian')
+ubuntu = process(scope, 'ubuntu')
+
+games = []
+for key in scope:
+ games.append({
+ 'name': key,
+ 'debian': debian.get(key, 0),
+ 'ubuntu': ubuntu.get(key, 0),
+ })
+
+games = sorted(games, key=lambda k: (-k['debian'], k['name']))
+
+print ('Package Debian Ubuntu')
+print ('-------------------------------------------------------------------')
+for package in games:
+ print('%49s %8d %8d' % (package['name'],
+ package['debian'],
+ package['ubuntu']))
diff --git a/tools/popcon.sh b/tools/popcon.sh
new file mode 100755
index 0000000..45ccc75
--- /dev/null
+++ b/tools/popcon.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+mkdir -p /var/cache/popcon/
+mkdir -p tmp
+
+date=$(date +%Y%m%d)
+wget http://popcon.debian.org/by_inst.gz --no-clobber --output-document=/var/cache/popcon/debian_$date.gz
+
+# the Ubuntu file is unreliably updated, sometimes it's stale for months
+last_ubuntu=$(cd /var/cache/popcon/ ; ls -1 ubuntu_201*.gz | tail -n 1)
+md5_old=$(md5sum /var/cache/popcon/$last_ubuntu | cut -f 1 -d ' ')
+
+wget http://popcon.ubuntu.com/by_inst.gz --no-clobber --output-document=tmp/ubuntu_$date.gz
+md5_new=$(md5sum tmp/ubuntu_$date.gz | cut -f 1 -d ' ')
+if [ ! "$md5_old" = "$md5_new" ]
+then
+ echo "New Ubuntu file"
+ mv tmp/ubuntu_$date.gz /var/cache/popcon/ -v
+else
+ echo "No Ubuntu update"
+ rm tmp/ubuntu_$date.gz
+fi
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git
More information about the Pkg-games-commits
mailing list