DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
transfer_check.py
Go to the documentation of this file.
1import os.path
2
3def check_contain_no_errors(bookkeeper_file_path):
4 """Check for errors in the bookkeeper file"""
5 with open(bookkeeper_file_path, 'r') as bookkeeper_file:
6 for line in bookkeeper_file:
7 if line.find("ERROR") != -1:
8 return False
9 return True
10
11def check_transfer_finished(bookkeeper_file_path, file_name):
12 """Check that the transfer is finished in the bookkeeper file"""
13 file_found = False
14 with open(bookkeeper_file_path, 'r') as bookkeeper_file:
15 for line in bookkeeper_file:
16 if line.find(file_name) != -1:
17 file_found = True
18 if line.find("FINISHED") == -1:
19 return False
20 return file_found
21
22def check_transfer_uploading(bookkeeper_file_path, file_name):
23 """Check that the transfer is uploading in the bookkeeper file"""
24 print('Check that the transfer is uploading in the bookkeeper file:', file_name)
25 file_found = False
26 with open(bookkeeper_file_path, 'r') as bookkeeper_file:
27 for line in bookkeeper_file:
28 if line.find(file_name) != -1:
29 file_found = True
30 if line.find("UPLOADING") == -1:
31 return False
32 return file_found
33
34def check_transfer_downloading(bookkeeper_file_path, file_name):
35 """Check that the transfer is downloading in the bookkeeper file"""
36 print('Check that the transfer is downloading in the bookkeeper file:', file_name)
37 file_found = False
38 with open(bookkeeper_file_path, 'r') as bookkeeper_file:
39 for line in bookkeeper_file:
40 if line.find(file_name) != -1:
41 file_found = True
42 if line.find("DOWNLOADING") == -1:
43 return False
44 return file_found
45
46def check_transfer_state(bookkeeper_file_path, file_name):
47 """Check transfer state in the bookkeeper file. Returning list with count(uploading, downloading, finished)"""
48 print('Check the transfer state in the bookkeeper logs for file:', file_name)
49 file_found = False
50 state = [0, 0, 0]
51 with open(bookkeeper_file_path, 'r') as bookkeeper_file:
52 for line in bookkeeper_file:
53 if line.find(file_name) != -1:
54 file_found = True
55 if "UPLOADING" in line:
56 state[0] += 1
57 elif "DOWNLOADING" in line:
58 state[1] += 1
59 elif "FINISHED" in line:
60 state[2] += 1
61 return state
62
check_transfer_uploading(bookkeeper_file_path, file_name)
check_transfer_state(bookkeeper_file_path, file_name)
check_contain_no_errors(bookkeeper_file_path)
check_transfer_downloading(bookkeeper_file_path, file_name)
check_transfer_finished(bookkeeper_file_path, file_name)