comparison directory_copier.py @ 1:1487421505f1 draft

Uploaded correct tool this time
author brenninc
date Wed, 23 Mar 2016 12:08:33 -0400
parents 25b07ce180d4
children 3911ee1a0078
comparison
equal deleted inserted replaced
0:25b07ce180d4 1:1487421505f1
6 6
7 def report_error(*args): 7 def report_error(*args):
8 sys.stderr.write(' '.join(map(str,args)) + '\n') 8 sys.stderr.write(' '.join(map(str,args)) + '\n')
9 sys.stderr.flush() 9 sys.stderr.flush()
10 sys.exit(1) 10 sys.exit(1)
11
12
13 def get_tool_data(name):
14 root_dir = os.path.dirname((os.path.realpath(__file__)))
15 path = os.path.join(root_dir,"tool-data",name)
16 if not(os.path.isfile(path)):
17 report_error(name,"file not found in tool's tool-data folder. Please ask you galaxy admin to add it back")
18 return path
19
20
21 def check_white_list(path_to_check):
22 white_list = get_tool_data("white-list.ini")
23 with open(white_list, 'r') as white_list_file:
24 for line in white_list_file:
25 line = line.strip()
26 if len(line) >= 1 and path_to_check.startswith(line):
27 return True
28 report_error(path_to_check,"has not been included in the white list. Please contact the local galaxy admin to add it.")
29
30
31 def check_black_list(path_to_check):
32 black_list = get_tool_data("black-list.ini")
33 with open(black_list, 'r') as black_list_file:
34 for line in black_list_file:
35 line = line.strip()
36 if len(line) >= 1 and line in path_to_check:
37 report_error(line,"has been black list so",path_to_check,"is not allowed. Please contact the local galaxy admin to change that, or add a symlink.")
38 return True
39 11
40 12
41 def check_pattern_get_new_name(a_file, ending, options): 13 def check_pattern_get_new_name(a_file, ending, options):
42 if options.start: 14 if options.start:
43 if not(a_file.startswith(options.start)): 15 if not(a_file.startswith(options.start)):
128 100
129 101
130 path = options.path.strip() 102 path = options.path.strip()
131 if path[-1] != '/': 103 if path[-1] != '/':
132 path = path + "/" 104 path = path + "/"
133 check_white_list(path)
134 print path, "white listed"
135 check_black_list(path)
136 print path, "not black listed"
137 copy_and_link(path, options) 105 copy_and_link(path, options)
138 106