[PATCH 1/6] NetTestController: change dir when running a python task
Ondrej Lichtner
olichtne at redhat.com
Fri Jun 12 11:53:37 UTC 2015
Ignore this patch-set, I just sent a new patch-set that fixes one of the
patches and adds two new ones.
On Thu, Jun 11, 2015 at 04:32:31PM +0200, olichtne at redhat.com wrote:
> From: Ondrej Lichtner <olichtne at 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 at 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
>
More information about the LNST-developers
mailing list