def run(include_log=True): stdout = sys.stdout stderr = sys.stderr if include_log: logout = StringIO() root_logger = logging.getLogger() log_level = root_logger.getEffectiveLevel() shandler = logging.StreamHandler(logout) shandler.setFormatter( logging.Formatter('%(levelname)s: %(message)s')) root_logger.addHandler(shandler) root_logger.setLevel(logging.INFO) success = False synthesized_commits = [] try: sys.stderr = sys.stdout = open(os.devnull, 'w') local.reify() success, synthesized_commits = gnumbd.inner_loop(local, cref, clock) except Exception: # pragma: no cover import traceback ret.append(traceback.format_exc().splitlines()) finally: sys.stdout = stdout sys.stderr = stderr if include_log: root_logger.removeHandler(shandler) root_logger.setLevel(log_level) # infra.libs.git2.repo logs this message if the command took longer than # 1s to run. This causes test flakes occasionally. log_lines = [x for x in logout.getvalue().splitlines() if 'Finished in ' not in x] ret.append({'log output': log_lines}) ret.append({ 'inner_loop success': success, 'synthesized_commits': [ { 'commit': c.hsh, 'footers': infra_types.thaw(c.data.footers), } for c in synthesized_commits ], })
def run(include_log=True): stdout = sys.stdout stderr = sys.stderr if include_log: logout = StringIO() root_logger = logging.getLogger() log_level = root_logger.getEffectiveLevel() shandler = logging.StreamHandler(logout) shandler.setFormatter( logging.Formatter('%(levelname)s: %(message)s')) root_logger.addHandler(shandler) root_logger.setLevel(logging.INFO) success = False synthesized_commits = [] try: sys.stderr = sys.stdout = open(os.devnull, 'w') local.reify() success, synthesized_commits = gnumbd.inner_loop( local, cref, clock) except Exception: # pragma: no cover import traceback ret.append(traceback.format_exc().splitlines()) finally: sys.stdout = stdout sys.stderr = stderr if include_log: root_logger.removeHandler(shandler) root_logger.setLevel(log_level) ret.append({'log output': logout.getvalue().splitlines()}) ret.append({ 'inner_loop success': success, 'synthesized_commits': [{ 'commit': c.hsh, 'footers': infra_types.thaw(c.data.footers), } for c in synthesized_commits], })
def outer_loop_iteration(): success, commits = gnumbd.inner_loop(opts.repo, cref) all_commits.extend(commits) commits_counter.increment_by(len(commits)) return success