The Python-based SCALE Client software for acquiring data from various sensors (i.e. via Raspberry Pi platform), processing it, and sharing it through multiple networks and data exchange protocols.
PyCharm resulted in absolute imports after Kyle's re-factory. These absolute imports cannot be resolved by Python 2. As a consequence, the clients no longer work if we attempt to run them like this:
cd /home/pi/SmartAmericaSensors/scale_client/core
./client_computer.py
Setting up environment variables may help solve this problem. We can run the clients with
cd /home/pi/SmartAmericaSensors/scale_client/core
env PYTHONPATH=/home/pi/SmartAmericaSensors ./client_computer.py
However, since our client will be registered as a daemon (also known as a Linux service) and will be called using start-stop-daemon, where environment variables are discarded, the solution above won't work in real deployments.
Tested working:
Having the following code paragraph at the beginning of the client file:
import sys
sys.path.append("/home/pi/SmartAmericaSensors"); # Path hard-coded in script
Tested NOT working:
Having PYTHONPATH set-up in /etc/environment
Having PYTHONPATH set-up in the daemon configuration file (/etc/init.d/scale).
Having env PYTHONPATH=/home/pi/SmartAmericaSensors before start-stop-daemon in the daemon configuration file.
Running the client with Python 3 (python3)
Not tested:
Using from __future__ import absolute_import in scripts
PyCharm resulted in absolute imports after Kyle's re-factory. These absolute imports cannot be resolved by Python 2. As a consequence, the clients no longer work if we attempt to run them like this:
Setting up environment variables may help solve this problem. We can run the clients with
However, since our client will be registered as a daemon (also known as a Linux service) and will be called using
start-stop-daemon
, where environment variables are discarded, the solution above won't work in real deployments.Tested working:
Tested NOT working:
PYTHONPATH
set-up in/etc/environment
PYTHONPATH
set-up in the daemon configuration file (/etc/init.d/scale
).env PYTHONPATH=/home/pi/SmartAmericaSensors
beforestart-stop-daemon
in the daemon configuration file.python3
)Not tested:
from __future__ import absolute_import
in scripts