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()
    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 __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(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()
示例#5
0
 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()
示例#6
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_local_mode(debug=False):
    global arg_options, arg_others, arg_rest
    proc, time_limit, memory_limit = get_args()
    total = len(proc)

    if total == 1:
        pypy = run_local_mode_one(proc[0], time_limit, memory_limit)
        GlobalResult.returncode = pypy.returncode
    else:
        # optionally we use counter
        progress = ProgressCounter('Running {:02d} of {total:02d}')
        for p in proc:
            Printer.separator()
            progress.next(locals())
            Printer.separator()

            Printer.open()
            pypy = run_local_mode_one(p, time_limit, memory_limit)
            Printer.close()
            GlobalResult.returncode = max(GlobalResult.returncode, pypy.returncode)

    return GlobalResult.returncode if not debug else pypy