Skip to content

Instantly share code, notes, and snippets.

@Alexhha
Last active June 23, 2017 14:54
Show Gist options
  • Save Alexhha/3d9ff7d90ec5c0198a608d238cd3b326 to your computer and use it in GitHub Desktop.
Save Alexhha/3d9ff7d90ec5c0198a608d238cd3b326 to your computer and use it in GitHub Desktop.
import cups
import subprocess
import time
conn = cups.Connection ()
printid = conn.printFile('ML2580N-1', '/tmp/test.txt', 'test', {})
print printid
stop = 0
TIMEOUT = 10
while str(subprocess.check_output(["lpstat"])).find(str(printid)) != 0 and stop < TIMEOUT:
stop += 1
time.sleep(1)
print "In queue"
if str(subprocess.check_output(["lpstat"])).find(str(printid)) == 0:
print "Transmitted"
else:
print "PRINT FAILURE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment