diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..77ebff9b5250398aa702f168daf435d268c299d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__* diff --git a/launch/test.launch b/launch/test.launch index 18af0e29e5f4406140bf5dec1039b7f66033e948..36add0f3e4d06ea4588e8f259dd7570c3c946cdc 100644 --- a/launch/test.launch +++ b/launch/test.launch @@ -13,7 +13,7 @@ <arg name="service_server_name" value="/test_node/service"/> <arg name="service_client_name" value="/test_node/service"/> <arg name="param_file" value="$(find iri_python_template)/config/params.yaml"/> - <arg name="virtual_env_path" value="$(arg virtual_env_path)"/> + <arg name="virtual_env_path" value="$(env HOME)/virtualenv/motion_prediction_venv"/> </include> <node pkg="rostopic" diff --git a/src/venv_utils.py b/src/venv_utils.py index 817c2c9d0d3ecc29aa4998927f92469b6c031d35..9e82ebcbbee4270bdcdcb21716011f580fe79bd4 100755 --- a/src/venv_utils.py +++ b/src/venv_utils.py @@ -1,6 +1,17 @@ import sys +def execfile(filepath, globals=None, locals=None): + if globals is None: + globals = {} + globals.update({ + "__file__": filepath, + "__name__": "__main__", + }) + with open(filepath, 'rb') as file: + exec(compile(file.read(), filepath, 'exec'), globals, locals) + + def activate_virtual_env(path=None, arg='--venv'): """ Activate Python Virtual Environment (virtualenv) within other python interpreter /or default interperter @@ -17,15 +28,18 @@ def activate_virtual_env(path=None, arg='--venv'): args = sys.argv[1:] path_to_venv = path.rstrip('/') if path is not None else args[args.index(arg) + 1].rstrip('/') activate_this = path_to_venv + activate_this - print "Activate Python Virtual Environment at: " + str(path_to_venv) - execfile(activate_this, dict(__file__=activate_this)) + print("Activate Python Virtual Environment at: " + str(path_to_venv)) + + #execfile(activate_this, dict(__file__=activate_this)) + execfile(activate_this) + return True except ValueError: - print "WARNING: No input path to Virtual ENV, will use default python" + print("WARNING: No input path to Virtual ENV, will use default python") return False except IOError: - print "WARNING: Wrong Input Path to Virtual ENV, will use default python" + print("WARNING: Wrong Input Path to Virtual ENV, will use default python") return False else: - print "WARNING: No input path to Virtual ENV, will use default python" + print("WARNING: No input path to Virtual ENV, will use default python") return False