Isolate loggers per document
This commit is contained in:
@ -33,6 +33,7 @@ from pyzebra import EXPORT_TARGETS, app
|
||||
|
||||
def create():
|
||||
doc = curdoc()
|
||||
log = doc.logger
|
||||
dataset1 = []
|
||||
dataset2 = []
|
||||
app_dlfiles = app.DownloadFiles(n_files=2)
|
||||
@ -94,7 +95,7 @@ def create():
|
||||
|
||||
def file_open_button_callback():
|
||||
if len(file_select.value) != 2:
|
||||
print("WARNING: Select exactly 2 .ccl files.")
|
||||
log.warning("Select exactly 2 .ccl files.")
|
||||
return
|
||||
|
||||
new_data1 = []
|
||||
@ -104,13 +105,13 @@ def create():
|
||||
f_name = os.path.basename(f_path)
|
||||
base, ext = os.path.splitext(f_name)
|
||||
try:
|
||||
file_data = pyzebra.parse_1D(file, ext)
|
||||
except:
|
||||
print(f"Error loading {f_name}")
|
||||
file_data = pyzebra.parse_1D(file, ext, log=log)
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
return
|
||||
|
||||
pyzebra.normalize_dataset(file_data, monitor_spinner.value)
|
||||
pyzebra.merge_duplicates(file_data)
|
||||
pyzebra.merge_duplicates(file_data, log=log)
|
||||
|
||||
if ind == 0:
|
||||
app_dlfiles.set_names([base, base])
|
||||
@ -133,7 +134,7 @@ def create():
|
||||
|
||||
def upload_button_callback(_attr, _old, _new):
|
||||
if len(upload_button.filename) != 2:
|
||||
print("WARNING: Upload exactly 2 .ccl files.")
|
||||
log.warning("Upload exactly 2 .ccl files.")
|
||||
return
|
||||
|
||||
new_data1 = []
|
||||
@ -142,13 +143,13 @@ def create():
|
||||
with io.StringIO(base64.b64decode(f_str).decode()) as file:
|
||||
base, ext = os.path.splitext(f_name)
|
||||
try:
|
||||
file_data = pyzebra.parse_1D(file, ext)
|
||||
except:
|
||||
print(f"Error loading {f_name}")
|
||||
file_data = pyzebra.parse_1D(file, ext, log=log)
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
return
|
||||
|
||||
pyzebra.normalize_dataset(file_data, monitor_spinner.value)
|
||||
pyzebra.merge_duplicates(file_data)
|
||||
pyzebra.merge_duplicates(file_data, log=log)
|
||||
|
||||
if ind == 0:
|
||||
app_dlfiles.set_names([base, base])
|
||||
@ -377,11 +378,11 @@ def create():
|
||||
scan_from2 = dataset2[int(merge_from_select.value)]
|
||||
|
||||
if scan_into1 is scan_from1:
|
||||
print("WARNING: Selected scans for merging are identical")
|
||||
log.warning("Selected scans for merging are identical")
|
||||
return
|
||||
|
||||
pyzebra.merge_scans(scan_into1, scan_from1)
|
||||
pyzebra.merge_scans(scan_into2, scan_from2)
|
||||
pyzebra.merge_scans(scan_into1, scan_from1, log=log)
|
||||
pyzebra.merge_scans(scan_into2, scan_from2, log=log)
|
||||
_update_table()
|
||||
_update_plot()
|
||||
|
||||
|
Reference in New Issue
Block a user