5 import subprocess, sys, os
6 from datetime
import datetime,timedelta
9 return datetime.strptime(time_str,
"%Y-%m-%dT%H:%M:%S+00:00")
12 return stime.strftime(
"mask.FD.%Y%m%d_%H00*.nhm")
15 """ get the file metadata as a dict""" 16 p = subprocess.Popen([
'samweb',
'get-metadata',fname],
17 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
18 resp_s,err=p.communicate()
19 if(len(err)):
print(
"### Error: "+err);
22 for line
in resp_s.split(
'\n'):
25 key=line[:pos].strip()
26 val=line[(pos+1):].strip()
31 """ Copy a noise channel mask here""" 32 p = subprocess.call([
'scp',
'novadaq@novadaq-far-trigger-2016.fnal.gov:/ddt/NoiseMaps/backup/'+fname,tgt])
38 parser = argparse.ArgumentParser(description=
'Fetch the noise channel mask for given file/timestamp')
39 parser.add_argument(
'FILE', help=
'A filename, which timestamp will be used')
40 parser.add_argument(
'--output',
'-o', default=
'.', help=
'Where to put the mask')
41 args = parser.parse_args()
54 print(
"Attempt #{}: fetching file {} to {}".
format(attempt,mapname,target))
58 print(
"Probably map doesn't exist, trying 1 hour before...")
60 stime-=timedelta(hours=1)
def fetch_map(fname, tgt)
std::string format(const int32_t &value, const int &ndigits=8)