mtrubs / intellibot

IntelliJ/PyCharm plugin for Robot Automation Framework
https://github.com/millennialmedia/intellibot/wiki
MIT License
158 stars 109 forks source link

Support for environment variables in resource path. #98

Open pselden opened 9 years ago

pselden commented 9 years ago

Is it possible to add support for environment variables when resolving resource paths?

For instance:

Resource            %{TESTS_HOME}/my_tests/resources.txt

Where TESTS_HOME is an environment variable that points to something like /Users/me/tests

Currently it just errors with "Import file not found"

mtrubs commented 9 years ago

where or how do you define %{TESTS_HOME}?

pselden commented 9 years ago

The %{} is used to tell Robot that it's an environment variable and not a defined variable.

For instance, in your bash profile or when running from the command line (different on Windows/Unix but here's with Unix + bash):

Inside your .bash_profile export TESTS_HOME=~/tests

From command line: TESTS_HOME=~/tests pybot test-suite.robot

This can be retrieved in Java as: System.getenv("TESTS_HOME");

mtrubs commented 9 years ago

how would one define these in intellij? I need to know how to setup my environment with one so that I know I can correctly get it out of the system.

pselden commented 9 years ago

They aren't Intellij specific things but rather "environment" (meaning your current login session) defined variables.

For windows: https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sysdm_advancd_environmnt_addchange_variable.mspx?mfr=true For unix/mac (depends what shell you use but instructions for multiple shells are here): http://www.cyberciti.biz/faq/set-environment-variable-unix/

Setting them is different depending on what operating system you're in, but they can always be retrieved with the System.getenv call in Java.

mtrubs commented 9 years ago

I get what they are and how one might use them. I do not understand how IntelliJ/PyCharm would be aware. So you are saying you just do an export in your bash profile and IntelliJ/PyCharm should be able to pick this up? Do you happen to know of any other plugins that are able to make use of this data? I can try testing out a couple of things but I worry that its going to be a little different (as everything seems to be with plugin development).

pselden commented 9 years ago

So you are saying you just do an export in your bash profile and IntelliJ/PyCharm should be able to pick this up

Ahh -- sorry I was being dense and didn't realize the issue here. From windows you can set "global" environment variables using the method mentioned in the article. From Mac you'd have to use something like mentioned here: http://www.dowdandassociates.com/blog/content/howto-set-an-environment-variable-in-mac-os-x-slash-etc-slash-launchd-dot-conf/ because IntelliJ won't be inheriting variables from your shell.

Note -- the IntelliJ python plugin just lets you enter environment variables directly (not sure if you'd actually need this if the other methods worked).

screen shot 2015-08-25 at 9 40 29 am

stdedos commented 5 years ago

Is this in any way planned?

Is the --variable flag support related to this / planned?