1
2
3 from glob import glob
4 import sys, os, subprocess, shlex, random, time, re
5
7 time.sleep(random.random())
8 all_checkpoints = ['20417.txt', '132.txt', '19699.txt', '4300.txt', '972.txt', '7ldvc10.txt', 'advsh12.txt']
9 this_checkpoint = random.choice(all_checkpoints)
10 current_checkpoints = glob('/usr/local/hadoop/user-tmp/dwmclary/hdmc_checkpoints/*')
11 for i in range(len(current_checkpoints)):
12 current_checkpoints[i] = re.sub('/usr/local/hadoop/user-tmp/dwmclary/hdmc_checkpoints/', '', current_checkpoints[i])
13 while this_checkpoint in current_checkpoints:
14 this_checkpoint = random.choice(all_checkpoints)
15 current_checkpoints = glob('/usr/local/hadoop/user-tmp/dwmclary/hdmc_checkpoints/*')
16 for i in range(len(current_checkpoints)):
17 current_checkpoints[i] = re.sub('/usr/local/hadoop/user-tmp/dwmclary/hdmc_checkpoints/', '', current_checkpoints[i])
18 if len(current_checkpoints) == len(all_checkpoints):
19 exit()
20
21 subprocess.call(['touch','/usr/local/hadoop/user-tmp/dwmclary/hdmc_checkpoints'+'/'+this_checkpoint])
22 subprocess.call(['chmod','777','/usr/local/hadoop/user-tmp/dwmclary/hdmc_checkpoints'+'/'+this_checkpoint])
23 os.system('chmod a+rwx line_counter.py')
24 cmd = ['./line_counter.py']+['./'+this_checkpoint]
25 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
26 output, error = p.communicate()
27 sts = p.wait()
28 print output
29
30
31 if __name__ == "__main__":
32 main()
33