import shutil, re, glob, sys, os from stat import * ERROR_STR= """Error removing %(path)s, %(error)s """ def rmgeneric(path, __func__): try: # print 'Removing file ', path __func__(path) # print 'Removed ', path except OSError, (errno, strerror): print ERROR_STR % {'path' : path, 'error': strerror }, errno def removeall(path): if not os.path.isdir(path): return files=os.listdir(path) for x in files: # print 'Removing ', x fullpath=os.path.join(path, x) if os.path.isfile(fullpath): os.chmod(fullpath, S_IWRITE) f=os.remove rmgeneric(fullpath, f) elif os.path.isdir(fullpath): removeall(fullpath) f=os.rmdir rmgeneric(fullpath, f) def del_temp_dir(dir): if dir: print 'Removing dir', dir if os.path.isdir(dir): removeall(dir) os.rmdir(dir) def temp_dir(log_file): pat = re.compile(".*Perforce repository directory (.*)\.$") #print "processing " + log_file result = [] input = open(log_file) for line in input: # print "line: " + line match = pat.match(line) if match: dir = match.group(1) print "Temp dir: " + dir result.append(dir) input.close() return result def main(): dirs = [] for file in ARGV: dirs.extend(temp_dir(file)) for dir in dirs: del_temp_dir(dir) if __name__ == '__main__': import sys, glob ARGV = sys.argv[1:] or glob.glob("*.log") main()
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 11893 | Robert Cowham |
Populate -o //guest/robert_cowham/perforce/P4OFC/main/... //guest/robert_cowham/perforce/P4OFC/icm/.... |
||
//guest/robert_cowham/perforce/P4OFC/main/test/tidy_dirs.py | |||||
#1 | 10843 | Robert Cowham |
Initial version of P4OFC source code. See README.txt (and LICENSE.txt and doc\P4OFC-Design.docx) |