tlog old packages to a file - amprolla - devuan's apt repo merger
 (HTM) git clone git://parazyd.org/amprolla.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 1e25c3e64883e6f06af6cc92b0dbc5d5d0bc5714
 (DIR) parent fd7239cebe21187c34ff7b4c56bd70ebf32716e2
 (HTM) Author: parazyd <parazyd@dyne.org>
       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(-)
       ---
 (DIR) diff --git a/lib/config.def.py b/lib/config.def.py
       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'
 (DIR) diff --git a/lib/log.py b/lib/log.py
       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()
 (DIR) diff --git a/lib/package.py b/lib/package.py
       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: