anxuae / pycups-notify Goto Github PK
View Code? Open in Web Editor NEWExtension to add notifications system to the pycups library (https://github.com/OpenPrinting/pycups)
License: MIT License
Extension to add notifications system to the pycups library (https://github.com/OpenPrinting/pycups)
License: MIT License
I am trying to use this library to trigger two functions, one for job related events and the other for printer related events. However, only the last subscription I have made, is being triggered.
from time import sleep
def on_cups_printer_event(evt):
print('Printer event')
print(evt)
def on_cups_job_event(evt):
print('Job event')
print(evt)
cups_subscription.subscribe(on_cups_job_event, [event.CUPS_EVT_JOB_CREATED, event.CUPS_EVT_JOB_COMPLETED, event.CUPS_EVT_JOB_STOPPED])
sleep(60)
cups_subscription.subscribe(on_cups_printer_event, [event.CUPS_EVT_PRINTER_ADDED, event.CUPS_EVT_PRINTER_MODIFIED, event.CUPS_EVT_PRINTER_DELETED, event.CUPS_EVT_PRINTER_CHANGED, event.CUPS_EVT_PRINTER_CONFIG_CHANGED, event.CUPS_EVT_PRINTER_STATE_CHANGED])
Doing this (left out the cups subscription) it will trigger on adding and removing jobs for 60 seconds, but after that, it will only trigger on the printer related events.
I am doing a simple print through cups in python3 on a Raspberry Pi. I do a very simple setup
` # Create a new subscriber
self.printerName = 'DYMO-LabelWriter-450'
cups.setUser(self.printerName)
self.sub = Subscriber(self.conn)
# Subscribe the callback
self.sub.subscribe(self.my_callback)#, [event.CUPS_EVT_JOB_CREATED])
`
and then start the print job. The printer is a DYMO label printer.
self.printId = self.conn.printFile(self.printerName, self.printFile, "Label", options)
The printer is completely done before I get any events and then they progress events with percentages start coming. They are at least several minutes behind the completion of the printing. Each progress comes about 10 or more seconds apart.
Any suggestions how to get it to respond in real time with what the printer is doing?
I got the following issue, any idea?
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 57540)
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 316, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 347, in process_request
self.finish_request(request, client_address)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 720, in __init__
self.handle()
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/server.py", line 426, in handle
self.handle_one_request()
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/server.py", line 414, in handle_one_request
method()
File "/Users/Vincent/Documents/git/venv/pibooth/lib/python3.7/site-packages/cups_notify/listener.py", line 67, in do_PUT
evts.append(event.CupsEvent(data))
File "/Users/Vincent/Documents/git/venv/pibooth/lib/python3.7/site-packages/cups_notify/event.py", line 43, in __init__
self.timestamp = self._parse_date(data)
File "/Users/Vincent/Documents/git/venv/pibooth/lib/python3.7/site-packages/cups_notify/event.py", line 50, in _parse_date
return datetime.strptime(date, "%a, %d %b %Y %H:%M:%S GMT")
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/_strptime.py", line 359, in _strptime
(data_string, format))
ValueError: time data 'Sun, 22 Mar 2020 15:43:32 GMT' does not match format '%a, %d %b %Y %H:%M:%S GMT'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.