-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSamplesChecker.py
More file actions
34 lines (28 loc) · 1.05 KB
/
Copy pathSamplesChecker.py
File metadata and controls
34 lines (28 loc) · 1.05 KB
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
#IMPORTING RELEVANT LIBRARIES
import os
import subprocess
# COUNTER FOR NUMBER OF CONTAINERS WITH LESS THAN 1M EVENTS
c=0
# OPENING FILE WITH SAMPLES TO CHECK
with open("samples.txt","r") as file:
# CHECKING EACH SAMPLE
for line in file:
output=subprocess.check_output("rucio list-files "+line,shell=True) #LIST FILES WITH RUCIO
info=output.split('\n')[-4:-1] #EXTRACT METADATA ON A LIST
n_events=float((info[2]).split(':')[1]) #GET NUMBER OF EVENTS
# CHECK IF CONTAINER HAS LESS THAN 1M EVENTS
if n_events<1000000:
c+=1
# WRITE INFORMATION OF EACH CONTAINER TO A FILE
info_file=open("info.txt","a")
info_file.write(line)
for x in info:
info_file.write(x+'\n')
info_file.write('-'*150+'\n')
info_file.close()
# PRINT A WARNING MESSAGE WITH NUMBER OF CONTAINERS WITH LESS THAN 1M EVENTS
if c==0:
print("All containers have more than 1M Events")
else :
print("WARNING!")
print("There are "+str(c)+" containers with less than 1M Events")