Add --print option.
This commit is contained in:
parent
1d4bf4813c
commit
23502e15f1
|
@ -11,6 +11,7 @@ import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import zeep
|
import zeep
|
||||||
|
|
||||||
|
@ -148,6 +149,8 @@ Frank and buy 2 stamps (creates 2 page document postage_YYYY-MM-DD.pdf):
|
||||||
$ frank ---format 26 --product 79 'Joe User;Street 1;12345 City' \\
|
$ frank ---format 26 --product 79 'Joe User;Street 1;12345 City' \\
|
||||||
'Jane User;Fakestreet 2;67890 Fakestadt'
|
'Jane User;Fakestreet 2;67890 Fakestadt'
|
||||||
|
|
||||||
|
It's also fine to delimit the recipient lines with newline characters.
|
||||||
|
|
||||||
2016, Georg Sauthoff <mail@georg.so>, GPLv3+
|
2016, Georg Sauthoff <mail@georg.so>, GPLv3+
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
@ -184,6 +187,8 @@ Frank and buy 2 stamps (creates 2 page document postage_YYYY-MM-DD.pdf):
|
||||||
metavar='FILENAME', help='machine specific config file')
|
metavar='FILENAME', help='machine specific config file')
|
||||||
p.add_argument('--update', action='store_true',
|
p.add_argument('--update', action='store_true',
|
||||||
help='update internal format list via webservice')
|
help='update internal format list via webservice')
|
||||||
|
p.add_argument('--print', action='store_true', default=False,
|
||||||
|
help='Print the retrieved PDF with the lpr command')
|
||||||
return p
|
return p
|
||||||
|
|
||||||
def parse_args(*xs):
|
def parse_args(*xs):
|
||||||
|
@ -361,6 +366,9 @@ def store_files(res, args):
|
||||||
log.info('Writing: {}'.format(filename))
|
log.info('Writing: {}'.format(filename))
|
||||||
with open(filename, 'wb') as f:
|
with open(filename, 'wb') as f:
|
||||||
f.write(pdf_bin)
|
f.write(pdf_bin)
|
||||||
|
if args.print:
|
||||||
|
log.info('Printing: {}'.format(filename))
|
||||||
|
subprocess.check_call(['lpr', filename])
|
||||||
|
|
||||||
def get_format(ident):
|
def get_format(ident):
|
||||||
for f in inema.formats:
|
for f in inema.formats:
|
||||||
|
@ -453,7 +461,7 @@ def main():
|
||||||
setup_logging()
|
setup_logging()
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
log.debug('Starting frank.py')
|
log.debug('Starting frank.py')
|
||||||
imain(args)
|
return imain(args)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
Loading…
Reference in New Issue