~fredg/twadeb

c4c0132ff4a8781328932bbd24a5d0a5bdbe6c27 — alienus 10 years ago cb0df37
remove dpkg & fix today list
1 files changed, 3 insertions(+), 15 deletions(-)

M twadeb.py
M twadeb.py => twadeb.py +3 -15
@@ 35,10 35,6 @@ parser.add_argument('-t', '--today', action="store_true",
        default=False,
        help='show today installed/upgraded packages')

parser.add_argument('-r', '--remove', action="store_true",
        default=False,
        help='use with --today, remove today installed packages')

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


@@ 62,7 58,6 @@ alldpkg = '/var/log/dpkg.*'
nb = int(args.nb)
full = args.full
today = args.today
remove = args.remove
#
#
#


@@ 121,20 116,13 @@ def lastNpkgs(nb):
         print('-'*72)
    for elt in lPkg:
        date, time, keyword, package, verbef, ver = elt
        if today and date == strftime("%Y-%m-%d"):
        if today:
            nb = nbPkgs
            if full:
                sys.exit(\
                'full option is useless with the today one, aborting...')
            print(package)
            if remove:
                print('Do you want to remove this package?: ')
                yn = input('Y(es)/N(o):')
                if yn == 'Y'or yn == 'y' or yn == 'Yes':
                    subprocess.call(["sudo", "dpkg", "-r", package])
                else:
                    sys.exit('Aborting...')
                
            if date == strftime("%Y-%m-%d"):            
                print(package)                
        elif full:
            keyword = keyword.replace('install', 'I').replace('upgrade', 'U')
            print(keyword, date, time, package.ljust(22), ver)