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)
def _take_lockfile(): return shellutils.lockfile(shellutils.mk_lock_filename())
# 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)