~fredg/twadeb

b6832e248c73362fb378bd003683d55353d34ff6 — alienus 10 years ago 1c702b3
build a full dpkg.log file
1 files changed, 23 insertions(+), 2 deletions(-)

M twadeb.py
M twadeb.py => twadeb.py +23 -2
@@ 10,10 10,10 @@
# Use the dpkg.log file to show last installed packages
#
#

import os
import gzip
import re

import glob

# Program information
my_url = 'https://gitlab.com/alienus/twadeb'


@@ 22,9 22,30 @@ my_version = '0.0.0'

# vars
dpkglog = '/var/log/dpkg.log.2.gz'
alldpkg = '/var/log/dpkg.*'
listFiles = []
fout = open('/tmp/dpkg.twadeb', 'a')
#


def dpkgFiles(alldpkg):
#    os.remove('/tmp/dpkg.twadeb')
    listFiles = glob.glob(alldpkg)
    sortFiles = sorted(listFiles)
    for l in sortFiles:
        if l.endswith(".gz"):
            with gzip.open(l, 'rt') as s:
                for li in s:
                    fout.write(li)
        else :
            with open(l, 'r') as s:
                for li in s:
                    fout.write(li)


dpkgFiles(alldpkg)


def parseLine(line):
    try:
        date, time, keyword, package, verbef, ver = line.split()