~fredg/twadeb

345f773c34696294c7cc7976da355b081f490557 — alienus 10 years ago 3c827af
fix yoday & full output
1 files changed, 11 insertions(+), 15 deletions(-)

M twadeb.py
M twadeb.py => twadeb.py +11 -15
@@ 36,7 36,7 @@ parser.add_argument('-t', '--today', action="store_true",
        help='show today installed/upgraded packages')

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

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


@@ 111,31 111,27 @@ def lastNpkgs(nb):
    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)
        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 today:
            nb = nbPkgs
            if full:
                sys.exit(\
                'full option is useless with the today one, aborting...')
            if date == strftime("%Y-%m-%d"):            
                print(package)                
            if date == strftime("%Y-%m-%d"):       
                print(package)      
        elif full:
            keyword = keyword.replace('install', 'I').replace('upgrade', 'U')
            print(keyword, date, time, '\t', package.ljust(22), ver)
            print(keyword, date, time, ' ', package.ljust(25), ver)
        else:
            print(package)


def main():
if __name__ == '__main__':
    # Build the dpkglog file (/tmp/dpkg.twadeb)
    dpkgFiles(alldpkg, dpkglog)
    #
    if full and today:
        sys.exit(\
            'full option is useless with the today one, aborting...')
    lastNpkgs(nb)


if __name__ == '__main__':
    main()