~fredg/twadeb

a909c3bfcf531a826b3de7978d08dd47c13a8584 — alienus 10 years ago 2d47c63
add show today installed packages
1 files changed, 23 insertions(+), 4 deletions(-)

M twadeb.py
M twadeb.py => twadeb.py +23 -4
@@ 16,6 16,8 @@ import gzip
import re
import glob
import argparse
from time import gmtime, strftime
import socket

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


@@ 26,10 28,14 @@ my_version = '0.0.0'
parser = argparse.ArgumentParser(
        prog='twadeb',
        description='Manage your last installed packages',
        epilog="i.e. twadeb -l 10")
        epilog="i.e. twadeb -l 20")

parser.add_argument('-t', '--today', action="store_true",
        default=False,
        help='show today installed/upgraded packages')

parser.add_argument('-l', '--list', action="store",
        dest='nb',
        dest='nb', default='10',
        help='list last NB installed/upgraded packages')

parser.add_argument('-f', '--full', action="store_true",


@@ 50,6 56,8 @@ dpkglog = '/tmp/dpkg.twadeb'
alldpkg = '/var/log/dpkg.*'
nb = int(args.nb)
full = args.full
today = args.today

#
#
#


@@ 102,11 110,22 @@ def lastNpkgs(nb):
        lPkg.append(infos)
    nbPkgs = len(lPkg)
    lPkg = lPkg[0:nb]
    if full and not today:
         print(socket.gethostname(), ':', \
               strftime("%Y-%m-%d %H:%M:%S"), '--', nbPkgs, 'packages')
         print('-'*72)
    for elt in lPkg:
        date, time, keyword, package, verbef, ver = elt
        if full:
        if today:
            if full:
                sys.exit(\
                'full option is useless with the today one, aborting...')
            nb = nbPkgs
            if date == strftime("%Y-%m-%d"):
                print(package)
        elif full:
            keyword = keyword.replace('install', 'I').replace('upgrade', 'U')
            print(keyword, date, time, package.ljust(24), ver)
            print(keyword, date, time, package.ljust(22), ver)
        else:
            print(package)