# The ultimate jobs versioning daemon. # Tail -f of journal, look for jobs, # update jobfile. # This requires p4job.py, p4s.py, submit_files.py, and # submit_mail.py path = 'C:\\perforce\\' # Path to Perforce journal file. journal = 'journal' # Name of Perforce journal file. import os, re, string, sys, p4job def findjob(singleline): if re.match('@db.job@', string.split(singleline, )[2]): # This line is entered in the journal if a job is created # or edited. m = re.match('^@(.*)@$', string.split(singleline, )[3]) p4job.makefile(m.group(1)) if re.match('@db.fix@', string.split(singleline, )[2]): # This line is entered in the journal if a job is fixed # or a fix is deleted. m = re.match('^@(.*)@$', string.split(singleline, )[3]) p4job.makefile(m.group(1)) def startail(): doit = 1 journalbuffer = os.popen('tail -f '+ path + journal, 'r') # Must have the Unix utility tail installed. while doit: oneline = journalbuffer.readline() if len(oneline) > 10: # An arbitrary number so findjob doesn't findjob(oneline) # try to parse a short output string. if __name__ == '__main__': # This keeps the module from being launched automatically # when it is imported. startail()