wait for printer
This commit is contained in:
parent
5de6b107d2
commit
58c5c98265
@ -9,6 +9,7 @@
|
||||
import sysv_ipc
|
||||
import pycstruct
|
||||
import os
|
||||
import time
|
||||
from brother_ql.brother_ql_create import create_label
|
||||
from brother_ql.raster import BrotherQLRaster
|
||||
import layouter
|
||||
@ -17,6 +18,7 @@ str_buffer_size = 64 #keep this synchronous to reHDD
|
||||
msg_queue_key = 0x1B11193C0 #keep this synchronous to reHDD
|
||||
|
||||
file_name = "output.png"
|
||||
printer_path = "/dev/usb/lp0"
|
||||
|
||||
def get_struct_format():
|
||||
#keep this synchronous to struct in reHDD
|
||||
@ -57,10 +59,15 @@ def main():
|
||||
shred_timestamp=int(driveData['driveShredTimestamp']),\
|
||||
shred_duration=int(driveData['driveShredDuration']))
|
||||
|
||||
while(not os.path.exists(printer_path)):
|
||||
print("Printer not found, waiting ...")
|
||||
time.sleep(30) #sleep 30
|
||||
|
||||
layouter.generate_image(drive, rehdd_info, file_name)
|
||||
qlr = BrotherQLRaster("QL-570")
|
||||
create_label(qlr, file_name, '62')
|
||||
with open("/dev/usb/lp0", 'wb') as file:
|
||||
|
||||
with open(printer_path, 'wb') as file:
|
||||
file.write(qlr.data)
|
||||
os.remove(file_name)
|
||||
except sysv_ipc.ExistentialError:
|
||||
|
Loading…
Reference in New Issue
Block a user