Reputation: 25
I have code in python which sets an environment variable and an alias to another code. E.g. when I run 'install.py' I get the environment variable and alias to a code named pyfem.py. I can use these and run the command pyfem (filename).pro
perfectly through the terminal to execute the program.
But when I use Eric, I am unable to run the program even after setting the environment variable in the run script dialog box. I have not found a way to set the alias to pyfem. So I feel that might be the problem.
Can someone please let me know how to set an alias through Eric? I have Ubuntu 14.04.
Upvotes: 0
Views: 175
Reputation: 7059
This is Python 2.7 code and both python programs in the same directory.
call_script.py
import os
from subprocess import call
if "OTHER_PROGRAM" in os.environ.keys():
program_name = os.environ["OTHER_PROGRAM"]
print "will execute", program_name
call([program_name ,"some_file.pro"])
else:
print "OTHER_PROGRAM env variable not defined"
other.py (must be marked executable - i.e.: chmod +x other.py)
#!/usr/bin/python
import sys
print "executing in other.py"
if len(sys.argv) > 1:
print "was passed value of ", sys.argv[1]
else:
print "no arguments were passed"
outputs:
executing in other.py
was passed value of some_file.pro
Upvotes: 0