def main(): # we don't do anything if we have another instance of us running lock_file = _take_lockfile() if lock_file is None: if config.DEBUG: print("Concurrent script in progress, exiting") sys.exit(1) next_task = read_next_task_by_state(config.TASKS.PENDING) if next_task is not None: print("Next task is", next_task) errtext = None out = None try: out = shellutils.run_shell_cmd("%s %s" % (os.path.join( os.path.dirname(__file__), "runner.py"), next_task)) except ShellCmdException as exc: print("Failed while running the test runner: %s", exc) errtext = exc.__str__() send_report(next_task, out, errtext) read_next_task_by_state(config.TASKS.INPROGRESS, next_task) else: print("No task") shellutils.unlockfile(lock_file)
def main(): # we don't do anything if we have another instance of us running lock_file = _take_lockfile() if lock_file is None: if config.DEBUG: print("Concurrent script in progress, exiting") sys.exit(1) next_task = read_next_task_by_state(config.TASKS.PENDING) if next_task is not None: print("Next task is", next_task) errtext = None out = None try: out = shellutils.run_shell_cmd("%s %s" % (os.path.join(os.path.dirname(__file__), "runner.py"), next_task)) except ShellCmdException as exc: print("Failed while running the test runner: %s", exc) errtext = exc.__str__() send_report(next_task, out, errtext) read_next_task_by_state(config.TASKS.INPROGRESS, next_task) else: print("No task") shellutils.unlockfile(lock_file)
def main(): lock_file = shellutils.lockfile(shellutils.mk_lock_filename(), retry=True) if lock_file is None: if config.DEBUG: print("Concurrent script in progress, exiting") sys.exit(1) subject = recv_mail(sys.stdin.read()) subject_parts = subject.split() if "[review-request]" in subject_parts: task_name = subject_parts[subject_parts.index("[review-request]") + 1] with open(config.BACKLOGFILE, "a") as fout: line = "%s|%s\n" % (task_name, config.TASKS.PENDING) fout.write(line) shellutils.unlockfile(lock_file)
# Designed to be run by the email system from a .forward file: # # cat .forward # |[full/path]/recv.py from __future__ import print_function import sys, os, config, shellutils from shellutils import ShellCmdException from email.parser import Parser def recv_mail(datastring): headers = Parser().parsestr(datastring) return headers['subject'] if __name__ == "__main__": lf = shellutils.lockfile(shellutils.mk_lock_filename(), retry = True) subject = recv_mail(sys.stdin.read()) subject_parts = subject.split() if "[review-request]" in subject_parts: task_name = subject_parts[subject_parts.index("[review-request]") + 1] with open(os.path.join(os.path.dirname(__file__), config.BACKLOGFILE), "a") as fout: line = "%s|%s\n" % (task_name, config.TASKS.PENDING) fout.write(line) shellutils.unlockfile(lf)
# # cat .forward # |[full/path]/recv.py from __future__ import print_function import sys, os, config, shellutils from shellutils import ShellCmdException from email.parser import Parser def recv_mail(datastring): headers = Parser().parsestr(datastring) return headers['subject'] if __name__ == "__main__": lf = shellutils.lockfile(shellutils.mk_lock_filename(), retry=True) subject = recv_mail(sys.stdin.read()) subject_parts = subject.split() if "[review-request]" in subject_parts: task_name = subject_parts[subject_parts.index("[review-request]") + 1] with open(os.path.join(os.path.dirname(__file__), config.BACKLOGFILE), "a") as fout: line = "%s|%s\n" % (task_name, config.TASKS.PENDING) fout.write(line) shellutils.unlockfile(lf)