1
0
Fork 0

plugins: fixed plugin_script, merging and handling

This commit is contained in:
Jaroslav Škarvada 2012-11-29 16:12:50 +01:00
parent c9fc7b2410
commit c83c7377f4
3 changed files with 10 additions and 5 deletions

View file

@ -16,7 +16,7 @@ class ScriptPlugin(base.Plugin):
if self._options["script"] is None:
return
self._scripts.append(self._options["script"])
self._scripts.extend(self._options["script"])
@classmethod
def tunable_devices(self):
@ -30,7 +30,7 @@ class ScriptPlugin(base.Plugin):
def _call_scripts(self, arg = "start"):
for script in self._scripts:
log.info("Calling script %s" % (script))
log.info("Calling script %s with arg %s" % (script, arg))
try:
proc = Popen([script, arg], stdout=PIPE, stderr=PIPE)
out, err = proc.communicate()

View file

@ -86,9 +86,9 @@ class Loader(object):
# TODO: HACK, this needs to be solved in a better way (better config parser)
for unit_name in config:
if config[unit_name].get("type", None) == "script" and "script" in config[unit_name]:
if "script" in config[unit_name] and config[unit_name].get("script", None) is not None:
dir_name = os.path.dirname(file_name)
script_path = os.path.join(dir_name, config[unit_name]["script"])
config[unit_name]["script"] = os.path.normpath(script_path)
config[unit_name]["script"] = [os.path.normpath(script_path)]
return config

View file

@ -32,6 +32,11 @@ class Merger(object):
profile_a.units[unit_name].type = unit.type
profile_a.units[unit_name].enabled = unit.enabled
profile_a.units[unit_name].devices = unit.devices
profile_a.units[unit_name].options.update(unit.options)
if unit_name == "script" and profile_a.units[unit_name].options.get("script", None) is not None:
script = profile_a.units[unit_name].options.get("script", None)
profile_a.units[unit_name].options.update(unit.options)
profile_a.units[unit_name].options["script"] = script + profile_a.units[unit_name].options["script"]
else:
profile_a.units[unit_name].options.update(unit.options)
return profile_a