Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import cups
  2. import subprocess
  3. import time
  4.  
  5. conn = cups.Connection ()
  6.  
  7. printid = conn.printFile('ML2580N-1', '/tmp/test.txt', 'test', {})
  8. print printid
  9.  
  10. stop = 0
  11. TIMEOUT = 20
  12.  
  13. while str(subprocess.check_output(["lpstat"])).find(str(printid)) != -1 and stop < TIMEOUT:
  14.     print "In queue"
  15.     stop += 1
  16.     time.sleep(1)
  17.  
  18. if str(subprocess.check_output(["lpstat"])).find(str(printid)) == -1:
  19.     print "Transmitted"
  20. else:
  21.     print "PRINT FAILURE"
  22.     conn.cancelJob(printid)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement