pyusb-keyboard-alike icon indicating copy to clipboard operation
pyusb-keyboard-alike copied to clipboard

ERROR RUNNING

Open hugopontesmiranda opened this issue 7 years ago • 8 comments

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

hugopontesmiranda avatar May 18 '17 11:05 hugopontesmiranda

You don't have pyusb installed.

riklaunim avatar May 18 '17 12:05 riklaunim

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

hugopontesmiranda avatar May 18 '17 13:05 hugopontesmiranda

can you help me?

hugopontesmiranda avatar May 18 '17 13:05 hugopontesmiranda

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...

riklaunim avatar May 18 '17 16:05 riklaunim

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

hugopontesmiranda avatar May 22 '17 08:05 hugopontesmiranda

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).

riklaunim avatar May 22 '17 15:05 riklaunim

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 .

hugopontesmiranda avatar May 22 '17 20:05 hugopontesmiranda

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.

riklaunim avatar May 22 '17 20:05 riklaunim