I am working on a project using a Beaglebone running Debian and I have python modules and scripts in a directory structure like this:
/home/debian/product/test (the scripts that I want to run)
/home/debian/product/src (a bunch of custom modules that need to get sourced by the above scripts)
I have this at the top of a typical script, call it "/home/debian/product/test/myscript.py":
sys.path.insert(1, '../src/')
from mymodule import *
{the rest of the script}
(mymodule.py is located in /home/debian/product/src)
This works fine if I login to the device in an interactive SSH session. I can do this:
cd /home/debian/product/test
python3 myscript.py
and it works fine. But for normal operation I need to control the device in a non-interactive SSH mode, by sending commands from a Windows command prompt. From the Windows command prompt I run a non-interactive ssh session to execute the command:
"C:\Program Files\PuTTy\plink" -batch -l debian -pw password 11.1.1.20 /usr/bin/python3 /home/debian/product/test/myscript.py
and I get this error: ModuleNotFoundError: No module named 'mymodule'
If I replace the sys.path.insert with an absolute path, it works properly from the Windows command line:
sys.path.insert(1, '/home/debian/product/src/')
The problem is that I perform my development on my PC using an IDE and using the absolute paths prevents my IDE from seeing the location of my modules during development (before I send the code to the device).
Is there any way to get a relative path to work on my target device when using a non-interactive SSH interface?