From: Ondrej Lichtner <olichtne(a)redhat.com>
This patch makes it so that we change into the directory containing the
python task before running it. This ensures that the developer can use
file paths relative to the location of the python taks.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/NetTestController.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index eeb6426..5c2695d 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -682,10 +682,13 @@ class NetTestController:
# Initialize the API handle
Task.ctl = Task.ControllerAPI(self, self._machines)
+ cwd = os.getcwd()
task_path = task["python"]
name = os.path.basename(task_path.abs_path()).split(".")[0]
sys.path.append(os.path.dirname(task_path.resolve()))
+ os.chdir(os.path.dirname(task_path.resolve()))
module = imp.load_source(name, task_path.resolve())
+ os.chdir(cwd)
sys.path.remove(os.path.dirname(task_path.resolve()))
#restore resource table
--
2.1.0