From f4a7d1c71f8dd11c03b6ee886d8d935af0db1956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= Date: Wed, 17 Jun 2015 23:41:00 +0200 Subject: [PATCH] plugin_script: CWD to the script directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows runnig helper scripts from the main script by just using the current directory './' path, e.g. to run helper_script from main script: ./helper_script Signed-off-by: Jaroslav Škarvada --- tuned/plugins/plugin_script.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tuned/plugins/plugin_script.py b/tuned/plugins/plugin_script.py index 8961de1..7b3d487 100644 --- a/tuned/plugins/plugin_script.py +++ b/tuned/plugins/plugin_script.py @@ -37,7 +37,8 @@ class ScriptPlugin(base.Plugin): log.info("calling script '%s' with argument '%s'" % (script, argument)) log.debug("using environment '%s'" % str(environ.items())) try: - proc = Popen([script, argument], stdout=PIPE, stderr=PIPE, close_fds=True, env=environ) + proc = Popen([script, argument], stdout=PIPE, stderr=PIPE, close_fds=True, env=environ, \ + cwd = os.path.dirname(script)) out, err = proc.communicate() if proc.returncode: log.error("script '%s' error: %d, '%s'" % (script, proc.returncode, err[:-1]))