command line utility for cups

Brian Oney brian.j.oney at googlemail.com
Wed Jun 20 05:28:38 EDT 2018


Dear all,

I am having trouble with argparse. I am trying to translate the following line to a sleek python
script:

lpr -o media=legal -o sides=two-sided-long-edge filename

Now where I am.

import argparse
parser = argparse.ArgumentParser(description='Print stuff with cups')
parser.add_argument('--printer', '-p',
                    help='Use this printer, try running: lpstat -a')
parser.add_argument('--options', '-o', 
                    help='Options for this printer, try running: \
                    lpoptions -p PRINTER -l')

parser.parse_known_args(['-o', 'sides=one-sided', '-o', 'test=crap'])
Namespace(options='test=crap', printer=None))

How should I deal with multiple options being fed into my script?

Thanks!

Cheers,
Brian


More information about the Python-list mailing list