joedougherty / distractinator Goto Github PK
View Code? Open in Web Editor NEWThe customizable, open source cubicle doorbell
License: MIT License
The customizable, open source cubicle doorbell
License: MIT License
While setting up distractinator
and trying to set up custom events, it took me a few tries to nail down where the config file is located: ~/.distractinator.conf
. Admittedly the distractd
setup process does print the location to STDOUT during configuration, but I missed it because I'm irresponsible and shouldn't be allowed near computers.
Simply placing a reference to it in the README may alleviate confusion for others.
Right now the README includes helpful examples for two methods of running distractd
as a service:
Most Linux distros have moved to systemd by now, and a seldom-used feature of systemd is that it provides a simple way to configure services management with normal user privileges, as long as the unit files are placed in ~/.config/systemd/user/
. For example, I'm now doing this:
$ cat ~/.config/systemd/user/distractd.service
[Unit]
Description=Distractinator Service Daemon
[Service]
ExecStart=/usr/bin/python %h/.local/bin/distractd
[Install]
WantedBy=default.target
Then a simple systemctl --user start distractd
and it's humming along nicely.
While running distractd
for the first time, the script correctly identified the USB device:
Press enter to continue!
[0]:
Device: /dev/ttyACM0
Manufacturer: Flora
Hardware ID: USB VID:PID=239A:8004 LOCATION=2-2
But selecting it via 0
to continue raised a serial.serialutil.SerialException
:
Select a port ('retry' if you still need to plug in the Distractinator(TM)): 0
[2016-12-03 16:10:18,111] INFO custom_script variable not set in config file.
[2016-12-03 16:10:18,111] INFO Attempting to find + connect to USB device...
[2016-12-03 16:10:18,117] INFO Found device at address: /dev/ttyACM0
Traceback (most recent call last):
File "/home/conor/.virtualenvs/distractinator/bin/distractd", line 9, in <module>
load_entry_point('distractinator==0.2', 'console_scripts', 'distractd')()
File "/home/conor/.virtualenvs/distractinator/local/lib/python2.7/site-packages/distractinator/__init__.py", line 4, in main
d = Distractinator()
File "/home/conor/.virtualenvs/distractinator/local/lib/python2.7/site-packages/distractinator/Distractinator.py", line 56, in __init__
self.p = self.autoconnect() # Won't you join me on the perennial quest?
File "/home/conor/.virtualenvs/distractinator/local/lib/python2.7/site-packages/distractinator/Distractinator.py", line 164, in autoconnect
return serial.Serial(p.device, 9600, timeout=10)
File "/home/conor/.virtualenvs/distractinator/local/lib/python2.7/site-packages/serial/serialutil.py", line 236, in __init__
self.open()
File "/home/conor/.virtualenvs/distractinator/local/lib/python2.7/site-packages/serial/serialposix.py", line 268, in open
raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 13] could not open port /dev/ttyACM0: [Errno 13] Permission denied: '/dev/ttyACM0'
This was caused by default device permissions on Ubuntu 16.04 requiring special group membership:
$ ls -l /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0 Dec 3 15:42 /dev/ttyACM0
Resolved it with:
$ sudo usermod -aG dialout $USER
$ newgrp dialout
Then reran the script and everything was hunky-dory. Would suggest two changes to help first-time users:
serial.serialutil.SerialException
and display an informative error message.It'd be grand to be able to install distractinator
via pip
without having to clone done this git repo. Just a thought!
My distractd
process died recently, but this output was only available via console.
This should at least be logged. It really ought to throw some kind of non-silent error (perhaps as a notification itself)?
1.) Figure out how to reproduce error.
2.) Log.
3.) Find appropriate notification mechanism to let user know the process died.
Example traceback:
Traceback (most recent call last):
File "/home/josepd/VENV/d2/lib/python3.6/site-packages/serial/serialposix.py", line 501, in read
'device reports readiness to read but returned no data '
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/josepd/VENV/d2/lib/python3.6/site-packages/distractinator/Distractinator.py", line 220, in run
serialMsg = port.readline().strip()
File "/home/josepd/VENV/d2/lib/python3.6/site-packages/serial/serialposix.py", line 509, in read
raise SerialException('read failed: {}'.format(e))
serial.serialutil.SerialException: read failed: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/josepd/VENV/d2/lib/python3.6/site-packages/serial/serialposix.py", line 501, in read
'device reports readiness to read but returned no data '
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/josepd/VENV/d2/bin/distractd", line 11, in <module>
sys.exit(main())
File "/home/josepd/VENV/d2/lib/python3.6/site-packages/distractinator/__init__.py", line 5, in main
d.run()
File "/home/josepd/VENV/d2/lib/python3.6/site-packages/distractinator/Distractinator.py", line 228, in run
serialMsg = port.readline().strip()
File "/home/josepd/VENV/d2/lib/python3.6/site-packages/serial/serialposix.py", line 509, in read
raise SerialException('read failed: {}'.format(e))
serial.serialutil.SerialException: read failed: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
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.