~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Leonard Richardson
  • Date: 2011-03-21 13:46:47 UTC
  • mto: This revision was merged to the branch mainline in revision 12658.
  • Revision ID: leonard.richardson@canonical.com-20110321134647-z4yvov4djcpr7833
Merge from trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
    setupInteractionByEmail,
40
40
    )
41
41
from canonical.lp import initZopeless
 
42
from lp.services.features import (
 
43
    getFeatureFlag,
 
44
    get_relevant_feature_controller,
 
45
    install_feature_controller,
 
46
    make_script_feature_controller,
 
47
    )
42
48
from lp.services.scripts.interfaces.scriptactivity import IScriptActivitySet
43
49
 
44
50
 
294
300
    @log_unhandled_exception_and_exit
295
301
    def run(self, use_web_security=False, isolation=None):
296
302
        """Actually run the script, executing zcml and initZopeless."""
 
303
 
297
304
        if isolation is None:
298
305
            isolation = ISOLATION_LEVEL_DEFAULT
299
306
        self._init_zca(use_web_security=use_web_security)
303
310
        profiler = None
304
311
        if self.options.profile:
305
312
            profiler = Profile()
 
313
 
 
314
        original_feature_controller = get_relevant_feature_controller()
 
315
        install_feature_controller(make_script_feature_controller(self.name))
306
316
        try:
307
317
            if profiler:
308
318
                profiler.runcall(self.main)
316
326
        else:
317
327
            date_completed = datetime.datetime.now(UTC)
318
328
            self.record_activity(date_started, date_completed)
 
329
        finally:
 
330
            install_feature_controller(original_feature_controller)
319
331
        if profiler:
320
332
            profiler.dump_stats(self.options.profile)
321
333