0

When I run lpr <filename>.jpg the file prints out boderless (this is what I want).

When I run subprocess.call("/usr/bin/lpr " + tmp.name, shell=True) from a Python program, it prints out with borders.

Output from lpoptions shows the below (StpBorderless=True, and StpiShrinkOutput=Expand should make it borderless I think).

How can I execute lpr from a Python script to use the exact same options as if I executed it from command line?

auth-info-required=none
copies=1
device-uri=usb://Canon/CP800?serial=DH00071100000840
finishings=3
job-hold-until=no-hold
job-priority=50
job-sheets=none,none
marker-change-time=0
number-up=1
printer-commands=none
printer-info='Canon CP800'
printer-is-accepting-jobs=true
printer-is-shared=false
printer-location printer-make-and-model='Canon SELPHY-CP770 - CUPS+Gutenprint v5.2.9'
printer-state=3
printer-state-change-time=1433298534
printer-state-reasons=none printer-type=2134028
printer-uri-supported=ipp://localhost:631/printers/Canon_CP800
StpBorderless=True
StpiShrinkOutput=Expand 

migrated from serverfault.com Jun 9 '15 at 3:15

This question came from our site for system and network administrators.

  • Why are using subprocess.call with shell=True? – Cristian Ciupitu Jun 6 '15 at 22:20
  • I thought using shell=True would make it behave more similar to running it from within the shell manually. – Brian McCarthy Jun 8 '15 at 19:21
  • 1
    Differences like that are often the result of differences in the environment variables. There may be program specific variables, or the program may be looking for config files in folders or search paths defines in an environment variable. – jelle foks Jun 9 '15 at 4:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy