~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/scripts/base.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-02 23:44:26 UTC
  • mfrom: (13589.1.1 revert-r13574)
  • Revision ID: launchpad@pqm.canonical.com-20110802234426-z03j07sj334l9ay0
[r=wgrant][rollback=13574] Revert r13574. It crashes when the flag is
 enabled, see bug #810290.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
    )
44
44
from canonical.lp import initZopeless
45
45
from lp.services.features import (
46
 
    UseFeatureController,
47
46
    get_relevant_feature_controller,
48
47
    install_feature_controller,
49
48
    make_script_feature_controller,
324
323
        if self.options.profile:
325
324
            profiler = Profile()
326
325
 
327
 
        with UseFeatureController(make_script_feature_controller(self.name)):
328
 
            try:
329
 
                if profiler:
330
 
                    profiler.runcall(self.main)
331
 
                else:
332
 
                    self.main()
333
 
            except LaunchpadScriptFailure, e:
334
 
                self.logger.error(str(e))
335
 
                sys.exit(e.exit_status)
336
 
            except SilentLaunchpadScriptFailure, e:
337
 
                sys.exit(e.exit_status)
 
326
        original_feature_controller = get_relevant_feature_controller()
 
327
        install_feature_controller(make_script_feature_controller(self.name))
 
328
        try:
 
329
            if profiler:
 
330
                profiler.runcall(self.main)
338
331
            else:
339
 
                date_completed = datetime.datetime.now(UTC)
340
 
                self.record_activity(date_started, date_completed)
 
332
                self.main()
 
333
        except LaunchpadScriptFailure, e:
 
334
            self.logger.error(str(e))
 
335
            sys.exit(e.exit_status)
 
336
        except SilentLaunchpadScriptFailure, e:
 
337
            sys.exit(e.exit_status)
 
338
        else:
 
339
            date_completed = datetime.datetime.now(UTC)
 
340
            self.record_activity(date_started, date_completed)
 
341
        finally:
 
342
            install_feature_controller(original_feature_controller)
341
343
        if profiler:
342
344
            profiler.dump_stats(self.options.profile)
343
345