| Date: Tue, 20 Jun 2017 10:35:45 +0200
log old packages to a file
Diffstat:
M lib/config.def.py | 1 +
M lib/log.py | 7 +++++++
M lib/package.py | 12 ++++++------
3 files changed, 14 insertions(+), 6 deletions(-)
--- |
| t@@ -7,6 +7,7 @@ amprolla configuration file
from hashlib import md5, sha1, sha256
cpunm = 4 # number of cpus you want to use for multiprocessing
+logdir = './log'
spooldir = './spool'
signingkey = 'CA608125'
mergedir = './merged' |
| t@@ -6,6 +6,7 @@ Logging functions
# TODO: Replace with logging
+import os
import sys
t@@ -27,3 +28,9 @@ def warn(msg):
def cleanexit():
notice("exiting cleanly...")
sys.exit(0)
+
+def logtofile(filename, text, redo=False):
+ os.makedirs(os.path.dirname(filename), exist_ok=True)
+ lf = open(filename, 'a')
+ lf.write(text)
+ lf.close() |
| t@@ -10,7 +10,8 @@ from gzip import open as gzip_open
from lzma import open as lzma_open
from shutil import copyfile
-from lib.config import mergedir, packages_keys, sources_keys, spooldir
+from lib.config import mergedir, packages_keys, sources_keys, spooldir, logdir
+from lib.log import logtofile
from lib.parse import parse_dependencies, parse_packages
t@@ -125,11 +126,10 @@ def merge_packages(pkg1, pkg2, name1, name2, banned_packages=set(),
pkg1_pkg = rewriter(pkg1_pkg, name1)
new_pkgs[pkg] = pkg1_pkg
if package_newer(pkg1_pkg, pkg2_pkg):
- # TODO: proper logfile
- print('There is a newer version of "%s"' %
- pkg1_pkg.get('Package'))
- print('Old version: %s' % pkg1_pkg.get('Version'))
- print('New version: %s' % pkg2_pkg.get('Version'))
+ logtofile(join(logdir, 'oldpackages.txt'),
+ '%s,%s,%s\n' % (pkg1_pkg.get('Package'),
+ pkg1_pkg.get('Version'),
+ pkg2_pkg.get('Version')))
elif pkg1_pkg:
if not package_banned(pkg1_pkg, banned_packages):
if rewriter: |