示例#1
0
 def __init__(self, n=4, name='runner', progress=True, case_format=False):
     super(ParallelThreads, self).__init__(name, progress)
     self.n = n if type(n) is int else 1
     if case_format:
         self.counter = ProgressCounter(
             '[{:02d} of {self.total:02d}] {self.current_thread.pypy}')
     else:
         self.counter = ProgressCounter(printer=None)
     self.stop_on_error = True
     self.i = 0
    def run_local_mode(self):
        """
        Runs this module in local mode.
        At this point arguments from cmd where parsed and converted.
        We create command arguments and prepare threads.

        If we need to run multiple jobs (for example cpu specification required
        to run this command using 1 AND 2 CPU) we call method run_local_mode_one
        repeatedly otherwise only once
        :rtype: PyPy
        """
        total = len(self.proc)
        result = ResultHolder()

        if total == 1:
            pypy = self.run_local_mode_one(self.proc[0])
            result.add(pypy)
        else:
            # optionally we use counter
            progress = ProgressCounter('Running {:02d} of {total:02d}')
            for p in self.proc:
                progress.next(locals())
                Printer.all.sep()

                with Printer.all.with_level():
                    pypy = self.run_local_mode_one(p)
                result.add(pypy)
                Printer.all.sep()

        return result.singlify()
示例#3
0
    def _run(self):
        if self.progress:
            if self.thread_name_property:
                self.counter = ProgressCounter(
                    '{self.name}: {:02d} of {self.total:02d} | {self.current_thread.name}'
                )
            else:
                self.counter = ProgressCounter(
                    '{self.name}: {:02d} of {self.total:02d}')

        with printf:
            while True:
                if not self.run_next():
                    break
                self.current_thread.join()

                if self.stop_on_error and self.current_thread.returncode > 0:
                    self.stopped = True
                    break
 def run(self):
     Printer.all.sep()
     Printer.all.out("Collecting artifacts...")
     Printer.all.sep()
     counter = ProgressCounter('Artifact step {:02d} / {total:02d}: {step}')
     total = len(self.steps)
     with Printer.all.with_level(1):
         for step in self.steps:
             counter.next(locals())
             with Printer.all.with_level(1):
                 step.run()
     Printer.all.sep()