Commit a0d613e2 authored by Holger Niemann's avatar Holger Niemann
Browse files

added pathvariables and a request to close the program to the upload

parent 1ca0a364
......@@ -41,6 +41,8 @@ dates=[[2017,11,9]]
temperature=False
only_upload_lattest=False
use_today=False
logpath=""#"C:\\QIR\\Upload\\"
temppath=""#"C:\\QIR\\Upload\\"
ports = ['AEF10', 'AEF11',
'AEF20', 'AEF21',
......@@ -120,11 +122,11 @@ original = sys.stdout
start=datetime.datetime.now()
fout=open("upload_log_"+str(start.date())+"_"+str(start.hour)+"_"+str(start.minute)+"_"+str(start.second)+".txt",'w')
fout=open(logpath+"upload_log_"+str(start.date())+"_"+str(start.hour)+"_"+str(start.minute)+"_"+str(start.second)+".txt",'w')
#foutf=open("upload_log_failes_"+str(start.date())+"_"+str(start.hour)+"_"+str(start.minute)+"_"+str(start.second)+".txt",'w')
sys.stdout = Tee(sys.stdout, fout)
#sys.stdout = fout
f_success=open("upload_log_successlist_"+str(start.date())+"_"+str(start.hour)+"_"+str(start.minute)+"_"+str(start.second)+".txt",'w')
f_success=open(logpath+"upload_log_successlist_"+str(start.date())+"_"+str(start.hour)+"_"+str(start.minute)+"_"+str(start.second)+".txt",'w')
#%% decide data path format
for date in dates:
if date[0]==2017 and date[1]<=9 and date[2]<=25:
......@@ -500,7 +502,7 @@ for date in dates:
trys=0
while (trys<retry and not success):
try:
response=IRup.upload_raw_data_from_H5(cameras[i],port,np.asarray(time1_0,dtype=np.int64),path+"\\"+rlist[fkeys[f1]],metadata1,parlog=raw_parlog,rawdata=raw_data,newversion=newversion,reason=reason,del_list=correction_list1)#upload cold and backgrounds
response=IRup.upload_raw_data_from_H5(cameras[i],port,np.asarray(time1_0,dtype=np.int64),path+"\\"+rlist[fkeys[f1]],metadata1,parlog=raw_parlog,rawdata=raw_data,newversion=newversion,reason=reason,del_list=correction_list1,temppath=temppath)#upload cold and backgrounds
if response[0]:
success=True
rawres1=1
......@@ -522,7 +524,7 @@ for date in dates:
while (trys<retry and not success):
print(datetime.datetime.now()," Upload second file")
try:
response=IRup.upload_raw_data_from_H5(cameras[i],port,np.asarray(time2_0,dtype=np.int64),path+"\\"+rlist[fkeys[f2]],metadata2,parlog=raw_parlog,rawdata=raw_data,del_list=correction_list2)#upload raw images from plasma
response=IRup.upload_raw_data_from_H5(cameras[i],port,np.asarray(time2_0,dtype=np.int64),path+"\\"+rlist[fkeys[f2]],metadata2,parlog=raw_parlog,rawdata=raw_data,del_list=correction_list2,temppath=temppath)#upload raw images from plasma
if response[0]:
success=True
rawres2=1
......@@ -589,4 +591,5 @@ for date in dates:
fout.close()
f_success.close()
#foutf.close()
sys.stdout = original
\ No newline at end of file
sys.stdout = original
char=input("upload is done, press any button to close the program.")
\ No newline at end of file
......@@ -9,6 +9,8 @@ upload_only_lattest=False
dates=[[2017,11,9]]
singlelist=[]
### settings ###
logpath="C:\\QIR\\Upload\\"
temppath="C:\\QIR\\Upload\\"
delete_Files=False
rawdata=True
raw1=True
......
......@@ -434,7 +434,7 @@ def regenerate_timevector(time,reftrig=1,tref=0,toff=0,give_program=False):
return np.asarray(time),"20000000.000"
def upload_raw_data_from_H5(camera,portnum,time,h5file,metadata={},comment="",parlog=True,rawdata=True,newversion=False,reason="",del_list=[]):
def upload_raw_data_from_H5(camera,portnum,time,h5file,metadata={},comment="",parlog=True,rawdata=True,newversion=False,reason="",del_list=[],temppath=""):
"""
upload_raw_data(camera,portnum,images,time,metadata={},newversion=False,reason="")
(str) camera: string of cameraname "IRCAM" or "INFRATEC", is used for the path
......@@ -473,7 +473,7 @@ def upload_raw_data_from_H5(camera,portnum,time,h5file,metadata={},comment="",pa
upload_Parlog(url,parobj,version)
if rawdata:
print("writing done, creating upload H5file")
tmp=writeH5_from_File(datastream_name,h5file,'images',time,double_list=del_list)
tmp=writeH5_from_File(datastream_name,h5file,'images',time,double_list=del_list,path=temppath)
print("uploading H5file")
if type(tmp) is list:
n=1
......@@ -1002,7 +1002,7 @@ def writeH5(stream,data,dimof,idx=None):
# g.create_dataset(dataname, data=data.tolist(), dtype=dtype,compression="gzip")
# return tmpfile
def writeH5_from_File(stream,filename,key,dimof,idx=None,double_list=[]):
def writeH5_from_File(stream,filename,key,dimof,idx=None,double_list=[],path=""):
"""
path=Path, data=numpy.array, dimof=list of long
data.shape = (width,height,time) or (width,height) if len(dim)==1
......@@ -1014,7 +1014,7 @@ def writeH5_from_File(stream,filename,key,dimof,idx=None,double_list=[]):
filesize=os.stat(filename).st_size
f5=h5reader.File(filename,'r')
if filesize<4000000000:
tmpfile = "archive_"+stream+'_'+str(dimof[0])
tmpfile = path+"archive_"+stream+'_'+str(dimof[0])
if idx: tmpfile += '_%d'%(idx,)
tmpfile += ".h5"
with h5reader.File(tmpfile, 'w') as f:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment