pyusb-keyboard-alike
pyusb-keyboard-alike copied to clipboard
ERROR RUNNING
I'm getting this
Traceback (most recent call last):
File "/home/pi/DosapacMirror/app.py", line 1, in <module>
from keyboard_alike import reader
File "/home/pi/DosapacMirror/keyboard_alike/reader.py", line 1, in <module>
import usb.core
ImportError: No module named 'usb'
i am trying to get input from a usb barcode scanner, but i need thist program to run in backgroud and alwayas reading and everytime it reads, it redirects to a page like "index.php?id=BARCODE_INPUT
please help me quickly
You don't have pyusb installed.
i had it installed but i solved that issue
but now i need to use in flask and i am getting errors with the reader
can you help me?
You can't run an event loop inside an other application thread without freezing it. In short you have to run pyusb event loop on it's own, put data to a queue, a cached list or whatever and then in a web application check if that data store has any data...
and could you help me caching and using it on flask i just need to cache it, than the flask web server read and redirects to web page and then it would be always reading
I already wrote that it can't run directly within flask! You must use a queue of some sort (memcached, redis, database) where reader process would insert and flask would read and delete (via some ajax hitting endpoint).
Yeah i understand that but how can i than everytime it reads redirect to page with that id? Piotr Maliński [email protected] escreveu em seg, 22/05/2017 às 16:52 :
I already wrote that it can't run directly within flask! You must use a queue of some sort (memcached, redis, database) where reader process would insert and flask would read and delete (via some ajax hitting endpoint).
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/riklaunim/pyusb-keyboard-alike/issues/6#issuecomment-303141322, or mute the thread https://github.com/notifications/unsubscribe-auth/AMBEuER7HM1Rb9sT_eeHFPn_c8mb9oHyks5r8a9RgaJpZM4NfFYq .
JavaScript function runs in interval and hits with ajax a flask endpoint view that returns a new record if present - if JS gets new data then it redirects.