简体   繁体   中英

Get eclipse run configuration arguments from script or environment variable (Pydev)

I am developing with openerp using PyDev on a Linux box.

So far I have to use 6 different run configurations, with an argument whose value is the same for all these configurations, and an other argument which is specific to each one.
Example: openerp -d <common_value> -u <specific_value>

I want to be able to do this : openerp -d $COMMON_VALUE -u <specific_value> , so that everytime I have to change the value of db, I don't have to go and change its value manually in all the six run configurations.

I tried to use environment variables, but these do not get reloaded even after I restart Eclipse. Would there be a way to read it from a bash script or other ?

Thank you for your help

Well, I think the best way in this case would be creating a launcher script (which in turn would fix sys.argv and call execfile with the openerp module) and create a launch for that module instead.

If you want, you can load that value from an environment variable (then set the environment variable in preferences > PyDev > Interpreters > Python Interpreter > Environment) -- and that's also the place you have to use to change it later on, as the process will by default inherit the environment variables that were used when Eclipse was started up.

Or load it from a file -- or leave it hardcoded and change on that module -- which may be the most straightforward way :)


Another option:

You can 'connect' your launch configurations to a file (run > run configurations > select the configuration > common > save as > shared file), that way you can do a search/replace to fix the run configurations (which should be faster than doing it in the UI).

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