简体   繁体   中英

How can I specify an alias in ERIC Python IDE?

I have code in python which sets an environment variable and an alias to another code. Eg 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.

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 - ie: 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM