-
Notifications
You must be signed in to change notification settings - Fork 0
/
collect_logs_dialog.py
48 lines (39 loc) · 1.29 KB
/
collect_logs_dialog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
import glob
#
# for exp in ["1","2","3"]:
# direct_path = "res_from_cluster/logs/active"+exp+"/"
# output = "./loginfo_exp_" + exp + ".txt"
# os.remove(output)
# for filename in os.listdir(direct_path):
# input = direct_path+filename
# print(input)
# with open(output, "a") as fw, open(input,"r") as fr: fw.writelines(l for l in fr)
def bad_files(num,name):
if name[0]=="0":
name = float(name[1])
else:
name = float(name)
# if num=="1" and name in [1,2]:
# return True
# if num=="9" and name<=30:
# return True
# if num=="10" and name<=15:
# return True
# if num =='11' and name<=6:
# return True
# if num =='12' and name<=4:
# return True
return False
direct_path = "res_from_cluster_dialog/logsDialog/active"
output = "./logs/clusterDialog/log_exp_"
files = glob.glob('./logs/clusterDialog/*')
for f in files:
os.remove(f)
for num in ['1','2','3','4','5','6','7','8','9']:
for filename in os.listdir(direct_path+num+"/"):
if not bad_files(num,filename[:2]):
input = direct_path+num+"/"+filename
print(" ", input)
with open(output+num+".txt", "a") as fw, open(input,"r") as fr:
fw.writelines(l for l in fr)