我有密码保护的多功能打印机(Panasonic DP8035),我无法从Ubuntu获得打印机输出。松下不愿意为此设备提供帮助,因为它的设备较旧。我想使用pycups lib获取打印机输出。
这是我简单的python脚本。我在网上找不到如何输入密码以获取打印机输出?
import cups
import time
import subprocess
main = 1
while main == 1:
conn = cups.Connection()
# Check the printers
printers = conn.getPrinters()
for printer in printers:
print(printer, printers[printer]['device-uri'])
printer_name = printers.key()[0]
time.sleep(0.1)
filename = '~/home/onur/Desktop/test.doc'
printid = conn.printFile(printer_name.filename, 'Python_Status_print', {})
time.sleep(5)
stop = 0
TIMEOUT = 5
while str(subprocess.check_output(['lpstat'])).find(str(printid)) > 0 and stop < TIMEOUT:
stop +- 1
time.sleep(0.5)
if stop < TIMEOUT:
print('Print success')
else:
print('Print failed')
main = 0