diff options
| author | Martin Sivak <msivak@redhat.com> | 2010-06-21 13:12:32 +0200 |
|---|---|---|
| committer | Martin Sivak <msivak@redhat.com> | 2010-06-21 13:12:32 +0200 |
| commit | 3e49679c9223518dd2b77897bd50f8f993f74540 (patch) | |
| tree | 4d0671c83c580b28c456628622c21b2036fb3374 /pyfirstaidkit | |
| parent | f28abaaab97f85a0d22f682942860389a3111c6f (diff) | |
| download | firstaidkit-3e49679c9223518dd2b77897bd50f8f993f74540.tar.gz firstaidkit-3e49679c9223518dd2b77897bd50f8f993f74540.tar.xz firstaidkit-3e49679c9223518dd2b77897bd50f8f993f74540.zip | |
Add a finer grained possibility to interrupt execution and do some tweaks in Gtk UI
Diffstat (limited to 'pyfirstaidkit')
| -rw-r--r-- | pyfirstaidkit/interpret.py | 18 | ||||
| -rw-r--r-- | pyfirstaidkit/plugins.py | 14 |
2 files changed, 24 insertions, 8 deletions
diff --git a/pyfirstaidkit/interpret.py b/pyfirstaidkit/interpret.py index 09e1641..17cb99e 100644 --- a/pyfirstaidkit/interpret.py +++ b/pyfirstaidkit/interpret.py @@ -58,7 +58,7 @@ class Tasker: self._backups = backups if pluginsystem is None: - self.pluginSystem = PluginSystem(reporting = self._reporting, + self.pluginSystem = PluginSystem(interpret = self, reporting = self._reporting, dependencies = self._provide, backups = self._backups) else: self.pluginSystem = pluginsystem @@ -69,6 +69,9 @@ class Tasker: "Tasker! This is not recommended.", level = TASKER, origin = self, importance = logging.WARNING) + def continuing(self): + return self._running + def flags(self): return self._provide @@ -131,6 +134,10 @@ class Tasker: oldlist = copy.copy(actlist) for plugin,flow in oldlist: + #If interruption was requested, stop + if not self._running: + break + #If plugin does not contain the automated flow or if #it ran correctly, remove it from list if ((flow and @@ -152,10 +159,11 @@ class Tasker: actlist.remove((plugin, flow)) #some plugins may not be called because of unfavorable flags - for plugin in set(map(lambda x: x[0], actlist)): - self._reporting.info("Plugin %s was not called because of " - "unsatisfied dependencies"% (plugin,), level = TASKER, \ - origin = self, importance = logging.WARNING) + if self._running: + for plugin in set(map(lambda x: x[0], actlist)): + self._reporting.info("Plugin %s was not called because of " + "unsatisfied dependencies"% (plugin,), level = TASKER, \ + origin = self, importance = logging.WARNING) # For the flags case elif self._config.operation.mode == "flags": diff --git a/pyfirstaidkit/plugins.py b/pyfirstaidkit/plugins.py index ae73ae6..0fe3852 100644 --- a/pyfirstaidkit/plugins.py +++ b/pyfirstaidkit/plugins.py @@ -110,7 +110,7 @@ class Plugin(object): default_flow = "diagnose" - def __init__(self, flow, reporting, dependencies, path = None, + def __init__(self, flow, reporting, dependencies, interpret = None, path = None, backups = None, info = None, args = None): """ Initialize the instance. @@ -129,6 +129,7 @@ class Plugin(object): self._backups = backups self._info = info self._args = args + self._interpret = interpret self.provide = dependencies.provide self.unprovide = dependencies.unprovide @@ -149,6 +150,12 @@ class Plugin(object): # self.defineFlow(flow) + def continuing(self): + if self._interpret: + return self._interpret.continuing() + else: + return True + def call(self, step): """call one step from plugin""" self._result = None #mark new unfinished step @@ -471,12 +478,13 @@ class PluginSystem(object): name = "Plugin System" - def __init__(self, reporting, dependencies, config=Config, backups=None): + def __init__(self, interpret, reporting, dependencies, config=Config, backups=None): self._paths = Config.paths.valueItems() self._backups = backups self._reporting = reporting self._reporting.start(level = PLUGINSYSTEM, origin = self) self._deps = dependencies + self._interpret = interpret self._plugins = {} for path in self._paths: @@ -624,7 +632,7 @@ class PluginSystem(object): infosection = getattr(Info, plugin) infosection.unlock() - p = pklass(flowName, reporting = self._reporting, + p = pklass(flowName, interpret = self._interpret, reporting = self._reporting, dependencies = self._deps, backups = self._backups, path = plugindir, info = infosection, args = " ".join(args)) for (step, rv) in p: #autorun all the needed steps |
