~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/job/runner.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-19 14:25:39 UTC
  • mfrom: (13701.1.6 twisted-logging)
  • Revision ID: launchpad@pqm.canonical.com-20110819142539-tkijmt573axhtnis
[r=jcsackett][bug=820510] Support --log-twisted flag in
 merge-proposal-jobs script.

Show diffs side-by-side

added added

removed removed

Lines of Context:
580
580
            rely on the subclass providing `config_name` and
581
581
            `source_interface`.
582
582
        """
 
583
        self._runner_class = runner_class
583
584
        super(JobCronScript, self).__init__(
584
585
            name=name, dbuser=None, test_args=test_args)
585
 
        self._runner_class = runner_class
 
586
        self.log_twisted = getattr(self.options, 'log_twisted', False)
586
587
        if not commandline_config:
587
588
            return
588
589
        self.config_name = self.args[0]
589
590
        self.source_interface = import_source(
590
591
            self.config_section.source_interface)
591
592
 
 
593
    def add_my_options(self):
 
594
        if self.runner_class is TwistedJobRunner:
 
595
            self.add_log_twisted_option()
 
596
 
 
597
    def add_log_twisted_option(self):
 
598
        self.parser.add_option(
 
599
            '--log-twisted', action='store_true', default=False,
 
600
            help='Enable extra Twisted logging.')
 
601
 
592
602
    @property
593
603
    def dbuser(self):
594
604
        return self.config_section.dbuser
617
627
            # utility default to using the [error_reports] config.
618
628
            errorlog.globalErrorUtility.configure(self.config_name)
619
629
        job_source = getUtility(self.source_interface)
 
630
        kwargs = {}
 
631
        if self.log_twisted:
 
632
            kwargs['_log_twisted'] = True
620
633
        runner = self.runner_class.runFromSource(
621
 
            job_source, self.dbuser, self.logger)
 
634
            job_source, self.dbuser, self.logger, **kwargs)
622
635
        for name, count in self.job_counts(runner.completed_jobs):
623
636
            self.logger.info('Ran %d %s jobs.', count, name)
624
637
        for name, count in self.job_counts(runner.incomplete_jobs):