~sylvain-pineau/cdts/bug1214914

« back to all changes in this revision

Viewing changes to plainbox/plainbox/impl/runner.py

  • Committer: Brendan Donegan
  • Date: 2013-09-05 07:32:35 UTC
  • mfrom: (2229.2.113 checkbox)
  • Revision ID: brendan.donegan@canonical.com-20130905073235-muq5qwjmwk9kcdtj
RebasedĀ onĀ lp:checkbox

Show diffs side-by-side

added added

removed removed

Lines of Context:
198
198
    _DRY_RUN_PLUGINS = ('local', 'resource', 'attachment')
199
199
 
200
200
    def __init__(self, session_dir, jobs_io_log_dir,
201
 
                 command_io_delegate=None, outcome_callback=None,
 
201
                 command_io_delegate=None, interaction_callback=None,
202
202
                 dry_run=False):
203
203
        """
204
204
        Initialize a new job runner.
211
211
        self._session_dir = session_dir
212
212
        self._jobs_io_log_dir = jobs_io_log_dir
213
213
        self._command_io_delegate = command_io_delegate
214
 
        self._outcome_callback = outcome_callback
 
214
        self._interaction_callback = interaction_callback
215
215
        self._dry_run = dry_run
216
216
 
217
217
    def run_job(self, job, config=None):
254
254
        return self._just_run_command(job, config)
255
255
 
256
256
    def _plugin_manual(self, job, config):
257
 
        # Run the shell command, we may be called
258
 
        # for user-interact and user-verify plugin types.
259
 
        result = self._just_run_command(job, config)
260
257
        # Get the outcome from the callback, if available,
261
258
        # or put the special OUTCOME_UNDECIDED value.
262
 
        if self._outcome_callback is not None:
263
 
            result.outcome = self._outcome_callback()
 
259
        if self._interaction_callback is not None:
 
260
            return self._interaction_callback(self, job, config)
264
261
        else:
265
 
            result.outcome = IJobResult.OUTCOME_UNDECIDED
266
 
        return result
 
262
            return DiskJobResult({'outcome': IJobResult.OUTCOME_UNDECIDED})
267
263
 
268
264
    _plugin_user_interact = _plugin_manual
269
265
    _plugin_user_verify = _plugin_manual