From bb4afcfbede3c7e04bc6c9213818cc5d9a60887c Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Mon, 8 Mar 2010 16:16:28 +0100 Subject: refs bug #429 use PATH variable to determine, if an executable file exists instead of just parsing the command string for a leading / --- lib/python/Components/Task.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib/python/Components/Task.py') diff --git a/lib/python/Components/Task.py b/lib/python/Components/Task.py index df94f8a6..86bd233e 100644 --- a/lib/python/Components/Task.py +++ b/lib/python/Components/Task.py @@ -370,12 +370,14 @@ class DiskspacePrecondition(Condition): class ToolExistsPrecondition(Condition): def check(self, task): import os - if task.cmd[0]=='/': - realpath = task.cmd - else: - realpath = task.cwd + '/' + task.cmd - self.realpath = realpath - return os.access(realpath, os.X_OK) + + self.realpath = task.cmd + path = os.environ.get('PATH', '').split(os.pathsep) + absolutes = filter(lambda file: os.access(file, os.X_OK), map(lambda directory, file = task.cmd: os.path.join(directory, file), path)) + if len(absolutes) > 0: + self.realpath = task.cmd[0] + return True + return False def getErrorMessage(self, task): return _("A required tool (%s) was not found.") % (self.realpath) -- cgit v1.2.3 From d0509622a73b8b84edf260599b853cab72903402 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Mon, 8 Mar 2010 17:25:37 +0100 Subject: refs bug #429 - allow absolute path names in Task.py but print a warning - search in task.cwd as well --- lib/python/Components/Task.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'lib/python/Components/Task.py') diff --git a/lib/python/Components/Task.py b/lib/python/Components/Task.py index 86bd233e..a1e04bce 100644 --- a/lib/python/Components/Task.py +++ b/lib/python/Components/Task.py @@ -371,12 +371,18 @@ class ToolExistsPrecondition(Condition): def check(self, task): import os - self.realpath = task.cmd - path = os.environ.get('PATH', '').split(os.pathsep) - absolutes = filter(lambda file: os.access(file, os.X_OK), map(lambda directory, file = task.cmd: os.path.join(directory, file), path)) - if len(absolutes) > 0: - self.realpath = task.cmd[0] - return True + if task.cmd[0]=='/': + self.realpath = task.cmd + print "[Task.py][ToolExistsPrecondition] WARNING: usage of absolute paths for tasks should be avoided!" + return os.access(self.realpath, os.X_OK) + else: + self.realpath = task.cmd + path = os.environ.get('PATH', '').split(os.pathsep) + path.append(task.cwd + '/') + absolutes = filter(lambda file: os.access(file, os.X_OK), map(lambda directory, file = task.cmd: os.path.join(directory, file), path)) + if len(absolutes) > 0: + self.realpath = task.cmd[0] + return True return False def getErrorMessage(self, task): -- cgit v1.2.3 From 58630f7b0de796e3589d2c1eaeb3e9d531d60d37 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Tue, 30 Mar 2010 16:58:54 +0200 Subject: save supposed afterEvent config in class Job member (fixes #394 DVDBurn shutdown not being executed) --- lib/python/Components/Task.py | 1 + lib/python/Screens/TaskView.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/python/Components/Task.py') diff --git a/lib/python/Components/Task.py b/lib/python/Components/Task.py index a1e04bce..2e4e757d 100644 --- a/lib/python/Components/Task.py +++ b/lib/python/Components/Task.py @@ -16,6 +16,7 @@ class Job(object): self.end = 100 self.__progress = 0 self.weightScale = 1 + self.afterEvent = None self.state_changed = CList() diff --git a/lib/python/Screens/TaskView.py b/lib/python/Screens/TaskView.py index eb926ca3..9907e2fb 100644 --- a/lib/python/Screens/TaskView.py +++ b/lib/python/Screens/TaskView.py @@ -7,7 +7,7 @@ import Screens.Standby from Tools import Notifications class JobView(InfoBarNotifications, Screen, ConfigListScreen): - def __init__(self, session, job, parent=None, cancelable = True, backgroundable = True, afterEvent = 0): + def __init__(self, session, job, parent=None, cancelable = True, backgroundable = True): from Components.Sources.StaticText import StaticText from Components.Sources.Progress import Progress from Components.Sources.Boolean import Boolean @@ -43,19 +43,20 @@ class JobView(InfoBarNotifications, Screen, ConfigListScreen): "ok": self.ok, }, -2) - self.afterevents = [ "nothing", "standby", "deepstandby", "close" ] self.settings = ConfigSubsection() if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") else: shutdownString = _("shut down") - self.settings.afterEvent = ConfigSelection(choices = [("nothing", _("do nothing")), ("close", _("Close")), ("standby", _("go to standby")), ("deepstandby", shutdownString)], default = self.afterevents[afterEvent]) + self.settings.afterEvent = ConfigSelection(choices = [("nothing", _("do nothing")), ("close", _("Close")), ("standby", _("go to standby")), ("deepstandby", shutdownString)], default = self.job.afterEvent or "nothing") + self.job.afterEvent = self.settings.afterEvent.getValue() self.setupList() self.state_changed() def setupList(self): self["config"].setList( [ getConfigListEntry(_("After event"), self.settings.afterEvent) ]) - + self.job.afterEvent = self.settings.afterEvent.getValue() + def keyLeft(self): ConfigListScreen.keyLeft(self) self.setupList() -- cgit v1.2.3