def run_thread(options, tracker): while True: try: task = tracker.fetch() except: task = None if not task: if options.sleep <= 0: return time.sleep(options.sleep) else: reaper = tinyback.Reaper(task) fileobj = reaper.run(options.temp_dir) tracker.put(task, fileobj, options.username) fileobj.close() if options.one_task: return
def run_thread(options, tracker): log = logging.getLogger("run_thread") while True: try: task = tracker.fetch() except: log.info("Error contacting tracker - Sleeping for 60 seconds") time.sleep(60) continue if not task: log.debug("Sleeping for %i seconds" % options.sleep) time.sleep(options.sleep) else: reaper = tinyback.Reaper(task) fileobj = reaper.run(options.temp_dir) try: tracker.put(task, fileobj, options.username) except: time.sleep(60) log.info("Error contacting tracker - Sleeping for 60 seconds") continue finally: fileobj.close()
message = record.getMessage() sys.stdout.write('\r ') sys.stdout.write(message) sys.stdout.flush() except (KeyboardInterrupt, SystemExit): raise except: self.handleError(record) handler = StreamHandlerWithProgress() handler.setFormatter( logging.Formatter("%(asctime)s %(name)s %(levelname)s: %(message)s")) logger = logging.getLogger() logger.addHandler(handler) logger.setLevel(logging.INFO) tracker = tinyback.tracker.Tracker(tracker) try: task = tracker.fetch() except: sys.exit(1) if not task: time.sleep(300) sys.exit(0) reaper = tinyback.Reaper(task, progress=True) fileobj = reaper.run(tmp_dir) tracker.put(task, fileobj, username) fileobj.close()
self._last_newline = False message = record.getMessage() sys.stdout.write('\r ') sys.stdout.write(message) sys.stdout.flush() except (KeyboardInterrupt, SystemExit): raise except: self.handleError(record) handler = StreamHandlerWithProgress() handler.setFormatter(logging.Formatter("%(asctime)s %(name)s %(levelname)s: %(message)s")) logger = logging.getLogger() logger.addHandler(handler) logger.setLevel(logging.INFO) tracker = tinyback.tracker.Tracker(tracker) try: task = tracker.fetch() except: sys.exit(1) if not task: time.sleep(300) sys.exit(0) reaper = tinyback.Reaper(task, progress=True) fileobj = reaper.run(tmp_dir) tracker.put(task, fileobj, username) fileobj.close()