Code Monkey home page Code Monkey logo

pycups-notify's People

Contributors

anxuae avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pycups-notify's Issues

Only last subscription is being triggered

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.

Notifications very slow to arrive

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?

Exception happened during processing of request

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'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.