Skip to content
Snippets Groups Projects
Commit 1d3ceac5 authored by rodolakis's avatar rodolakis
Browse files

log_update fixed

parent 39c040c7
No related branches found
No related tags found
No related merge requests found
......@@ -25,14 +25,11 @@ def log_update(d=None):
updates the log file with the last scan info
d = dictionary of {header:[data,format]}
"""
try:
if d == None:
d = iex.BL.mda.log.log_dictionary()
iex.BL.mda.log.update(d)
#try:
iex.BL.mda.log.update(d)
except:
print('No logfile written')
#except:
# print('No logfile written')
def log_name_set(file_name):
try:
......@@ -193,13 +190,13 @@ class Logfile:
entry+=item+","
f.write(entry[:-1] +'\n\n')
def write_entry(self,data_list, format_list):
def write_entry(self, head_list, data_list, format_list):
"""
writes an entry to the logfile
"""
if not isfile(self.filepath):
self.write_header()
self.write_header(head_list)
with open(self.filepath, "a+") as f:
for i in range(len(format_list)):
......@@ -209,19 +206,22 @@ class Logfile:
pv_format="{0:"+format_list[last_entry]+"}\n"
f.write(pv_format.format(data_list[last_entry]))
def update(self):
def update(self,d=None):
"""
To be used for scanlog and scanEA functions.
Update SaveFile_Header version number when changing the structure of the file (indexing).
Previously: SaveFile
"""
header_list,data_list,format_list = self.log_entries()
if d == None:
d = iex.BL.mda.log.log_dictionary()
header_list,data_list,format_list = self.log_entries(d)
if not isfile(self.filepath):
self._intit_log(header_list)
self.write_entry(self,data_list, format_list)
self.write_entry(header_list,data_list,format_list)
......@@ -166,8 +166,7 @@ def EAlog_update():
"""
d=EA_log_dictionary()
try:
header_list,data_list,format_list = iex.BL.mda.log.log_entries(d)
iex.BL.mda.log.write_entry(data_list,format_list)
log_update(d)
except:
print("EAlog did not write to file, check for errors.")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment