7success_marker =
"FINISH (event"
11 options, remainder = getopt.getopt(sys.argv[1:],
"hi:r",[
"help",
"input",
"remove"])
12except getopt.GetoptError:
13 print 'USAGE: python check_success.py -i \"[<input_direcory>,<regular_expression_files>]\" [--remove]\n'
18for opt, arg
in options:
19 if opt
in (
'-h',
'--help'):
20 print 'USAGE: python check_success.py -i \"[<input_direcory>,<regular_expression_files>]\" [--remove]\n'
22 elif opt
in (
'-i',
'--input'):
24 elif opt
in (
'-r',
'--remove'):
28 print 'USAGE: python check_success.py -i \"[<input_direcory>,<regular_expression_files>]\"\n'
31if file_list.endswith(
"/"):
34 if os.path.isdir(file_list):
41for file
in glob.glob(file_list):
42 if not os.path.isfile(file):
continue
46 with open(file)
as fp:
47 s = mmap.mmap(fp.fileno(), 0, access=mmap.ACCESS_READ)
48 if s.find(success_marker) == -1:
50 print(file +
': marker not found')
51 elif remove_option ==
True:
53 if delete_flag ==
True:
57 print(
'There are no files in "'+ file_list +
'" or directory does not exist')
59 if is_nfound ==
False:
60 print(
'All files are correct in "'+ file_list)