-
Notifications
You must be signed in to change notification settings - Fork 5
/
preparer_test.py
72 lines (52 loc) · 1.92 KB
/
preparer_test.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import os
from os import listdir
from os.path import isfile, join
def get_list_of_queue_files(queue):
files = [queue+ '/' +f for f in listdir(queue) if isfile(join(queue, f))]
files = [ file for file in files if "m_install_" in file ]
return files
def check_if_tested_before_file(full_file_name, file_name):
completed_files = get_list_of_queue_files("completed")
for current_file_name in completed_files:
current_file_name = get_just_the_file_name(current_file_name)
if s_compare(current_file_name,file_name):
return True
return False
def get_only_program_name(file_name):
#file_name = ''.join([i for i in file_name if not i.isdigit()])
file_name = file_name.split('/')[-1]
file_name = file_name.replace('m_install_','')
toberemoved = file_name.split('_')[0]
file_name = file_name.replace(toberemoved,'')[1:]
return file_name
def get_list_of_file_names(files):
new_list_of_files = []
for file in files:
try:
new_list_of_files.append(get_only_program_name(file)+'\n')
except:
pass
return new_list_of_files
# files = get_list_of_queue_files("completed")
# new_list_of_files = get_list_of_file_names(files)
# f = open("completed.txt", "a")
# f.writelines(new_list_of_files)
# f.close()
def set_completed_file(full_file_name, file_name):
command = 'mv '+ full_file_name +' /tmp/'+ file_name
file_name = get_only_program_name(file_name)
print(command)
if Run:
os.system(command)
command = 'echo "' + file_name + '" >> completed/completed.txt'
print(command)
if Run:
os.system(command)
def read_all_lines(file_name):
with open(file_name,'r') as f:
output = f.read()
return output.split('\n')
def check_if_tested_before(file_name):
files = read_all_lines('completed/completed.txt')
return file_name in files
append_to_file('completed/completed.txt','line')