Skip to content

Commit

Permalink
use environment variables (#740)
Browse files Browse the repository at this point in the history
* use environment variables
  • Loading branch information
temetski committed Sep 27, 2019
1 parent 3c01094 commit 180e063
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ before_install:
- ./flow/scripts/setup_aimsun.sh
- popd
- source ~/.bashrc
- sed -i 's/\/path\/to\/envs\/aimsun_flow/\/home\/travis\/miniconda\/envs\/aimsun_flow/g' flow/config.py
- export AIMSUN_SITEPACKAGES="/home/travis/miniconda/envs/aimsun_flow"
- export AIMSUN_NEXT_PATH="/home/user/Aimsun_Next_XXX"

- ls ../

Expand Down
13 changes: 8 additions & 5 deletions docs/source/flow_setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ can be achieved by following the installation instructions located in:
https://www.aimsun.com/aimsun-next/download/.

Once Aimsun has been installed, copy the path to the `Aimsun_Next` main
directory and place it in under the `AIMSUN_NEXT_PATH` variable in the
"flow/config.py" folder. This will allow Flow to locate and use this binary
directory and place it in under the `AIMSUN_NEXT_PATH` variable in your bashrc.
This will allow Flow to locate and use this binary
during the execution of various tasks. The path should look something like:

::

/home/user/Aimsun_Next_X_Y_Z/ # Linux
/Applications/Aimsun Next.app/Contents/MacOS/ # OS X
export AIMSUN_NEXT_PATH="/home/user/Aimsun_Next_X_Y_Z/" # Linux
export AIMSUN_NEXT_PATH="/Applications/Aimsun Next.app/Contents/MacOS/" # OS X

`Note for Mac users:` when you download Aimsun, you will get a folder named "Programming". You need to rename it to "programming" (all lowercase) and to move it inside the "Aimsun Next.app/Contents/MacOS/" directory so that the python API can work.

Expand Down Expand Up @@ -178,8 +178,11 @@ The latter command should return an output similar to:
/path/to/envs/aimsun_flow/bin/python

Copy the path up until right before /bin (i.e. /path/to/envs/aimsun_flow) and
place it under the `AIMSUN_SITEPACKAGES` variable in flow/config.py.
place it under the `AIMSUN_SITEPACKAGES` variable in your bashrc, like this:

::

export AIMSUN_SITEPACKAGES="/path/to/envs/aimsun_flow/bin/python"

Testing your installation
~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions flow/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
AWS_S3_PATH = "s3://bucket_name"

# path to the Aimsun_Next main directory (required for Aimsun simulations)
AIMSUN_NEXT_PATH = "/home/user/Aimsun_Next_XXX"
AIMSUN_NEXT_PATH = os.environ.get("AIMSUN_NEXT_PATH", None)

# path to the aimsun_flow environment's main directory (required for Aimsun
# simulations)
AIMSUN_SITEPACKAGES = "/path/to/envs/aimsun_flow"
AIMSUN_SITEPACKAGES = os.environ.get("AIMSUN_SITEPACKAGES", None)
18 changes: 12 additions & 6 deletions flow/utils/aimsun/scripting_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@

import flow.config as config

SITEPACKAGES = os.path.join(config.AIMSUN_SITEPACKAGES,
"lib/python2.7/site-packages")
sys.path.append(SITEPACKAGES)

sys.path.append(os.path.join(config.AIMSUN_NEXT_PATH,
'programming/Aimsun Next API/AAPIPython/Micro'))
try:
SITEPACKAGES = os.path.join(config.AIMSUN_SITEPACKAGES,
"lib/python2.7/site-packages")
sys.path.append(SITEPACKAGES)
except TypeError:
raise EnvironmentError("Please declare the AIMSUN_SITEPACKAGES environment variable.")

try:
sys.path.append(os.path.join(config.AIMSUN_NEXT_PATH,
'programming/Aimsun Next API/AAPIPython/Micro'))
except TypeError:
raise EnvironmentError("Please declare the AIMSUN_NEXT_PATH environment variable.")


class AimsunTemplate(object):
Expand Down

0 comments on commit 180e063

Please sign in to comment.