python sys.path versus code hack
in distributing some python from an automation-orchestration host to a
remote-client and a remote-server I found that hacking on the path is
better than moving modules. However, this did not click well with another
dev and we had interference. I chose a bad hack, he chose another perhaps
equivalent hack. I think now both are wrong:
hack #1:
# on remote systems the dir is flat, on local automation host it is less
flat!
try:
from process import call_process
except:
from common.process import call_process
hack #2
# in deployment steps
ssh qa$host
mkdir common
touch common/__init__.py
cp common/process.py $HOST:common/process.py
I think the better thing would be to leave it as a PYTHONPATH or syspath
solution:
add_path( TEST_ROOT+'/common')
from process import call_process
Constructive perspectives welcome! /Mike
No comments:
Post a Comment