Example #1
0
    return printers

def get_balance(sessID):
    print '\nYour balance is now: $ %.2f' % (int(papercut.getBalance(sessID)) / 100.0)



if args.password_options or not password:
    password = getpass.getpass()
    
if args.password_options == 'save':
    keyring.set_password('papercut', username, password)
    print "password saved in keyring"

if args.list or args.balance or args.printjob or args.printer:
    sessID = papercut.login(username, password)
    if sessID:
        print '\nLogged in to PaperCut with session ID',sessID
        if args.list: list_printers(sessID)
        if args.balance: get_balance(sessID)
        if args.printjob:
            if not args.printer:
                printers = list_printers(sessID)
                args.printer = raw_input('select printer: ')
                try:
                    printerIndex = int(args.printer)
                    args.printer = printers[printerIndex][1]
                except ValueError:
                    pass
                printJobID = papercut.printFile(args.printjob, args.printer, sessID)
                print '\nJob sent to printer', args.printer
Example #2
0

def get_balance(sessID):
    print '\nYour balance is now: $ %.2f' % (int(papercut.getBalance(sessID)) /
                                             100.0)


if args.password_options or not password:
    password = getpass.getpass()

if args.password_options == 'save':
    keyring.set_password('papercut', username, password)
    print "password saved in keyring"

if args.list or args.balance or args.printjob or args.printer:
    sessID = papercut.login(username, password)
    if sessID:
        print '\nLogged in to PaperCut with session ID', sessID
        if args.list: list_printers(sessID)
        if args.balance: get_balance(sessID)
        if args.printjob:
            if not args.printer:
                printers = list_printers(sessID)
                args.printer = raw_input('select printer: ')
                try:
                    printerIndex = int(args.printer)
                    args.printer = printers[printerIndex][1]
                except ValueError:
                    pass
                printJobID = papercut.printFile(args.printjob, args.printer,
                                                sessID)