I’ve been working on webcontrol for a while to customize it for the raspberry pi to use some features only available on the raspberry pi and have tried a number of things and I’m kind of stuck and looking for ideas on how to correctly approach the problem.
As it is set up, the buttons and Led’s don’t work (because of gevent used for flask or socket conflicts with gpiozero), so I tried 2 approaches:
The first approach was to make a button service that then called a pendant service (systemctl in systemd with .service files). This works, but requires root permissions to run and is difficult to manage starting / stopping of the service and has a hardcoded port number, so if user changes it in webcontrol, it doesn’t work anymore, but this worked.
The problem with the first was that the file had to be copied by a sudo command and run by a sudo command from a specific location. the dependencies were light though, so it likely wouldn’t be hard for a user to set up, but this type of operational mode is frowned upon. There are several batch files that accompany it and it lacked the ability to easily change ports. I don’t know where or how this fits in with a webcontrol release though it communicates with webcontrol via the socket IO.
The second approach was to make a button and LED subprocess that ran from webcontrol as an orphan that could be killed and restarted. The truth of the matter is that my code fu is on a white belt level. In theory once the syntax is correct and I get past the weird file not found and maximum recursion depth errors, it should work.
The second is supposed to be managed from webcontrol. Instead of 4 files, it only has 2 and no root privileges are required. It runs fine independently, but when subprocess.Popen() is used to execute a batch file to start the python code from within webcontrol, it throws a recursion depth error and does not run. I made the MaslowButton.py file house a class that runs from main.
So what is the “right” way to do this? I also have a cool idea for my controller LED I’d like to implement and I think others would appreciate, but I need some help getting the button part to run before I can try it and share it. Any suggestions or references for study would be appreciated.