Commit b4af3217 authored by Fabian Wachsmann's avatar Fabian Wachsmann
Browse files

dry

parent adbbfa39
......@@ -96,13 +96,24 @@
[0] Markdown(str)
%% Cell type:code id: tags:
``` python
def toggle_button(button):
if button.disabled:
button.disabled = False
button.loading = False
else :
button.disabled = True
button.loading = True
```
%% Cell type:code id: tags:
``` python
def try_swift_container_input(b):
validate_container.disabled=True
validate_container.loading=True
toggle_button(validate_container)
[validate_container_output.pop(0) for i in range(len(validate_container_output))]
input_missing=False
for inputobject in os_config:
if not inputobject.value:
validate_container_output.append("Please specify {0}!".format(inputobject.name))
......@@ -110,28 +121,25 @@
for inputobject in name_config:
if not inputobject.value:
validate_container_output.append("Please specify {0}!".format(inputobject.name))
input_missing=True
if input_missing :
validate_container.disabled=False
validate_container.loading=False
toggle_button(validate_container)
return False
try:
container = tzis.Tzis(url.value,
token.value,
container_name.value,
verbose=verbose.value
)
container.open_store(zarr_dataset_name.value)
validate_container.disabled=False
validate_container.loading=False
toggle_button(validate_container)
validate_container_output.append("Verified Swift Container Input!")
return container
except Exception as e:
validate_container.disabled=False
validate_container.loading=False
toggle_button(validate_container)
validate_container_output.append(e)
return False
validate_container.on_click(try_swift_container_input)
```
......@@ -199,12 +207,11 @@
%% Cell type:code id: tags:
``` python
def try_dataset_input(c):
validate_dataset.disabled=True
validate_dataset.loading=True
toggle_button(validate_dataset)
[validate_dataset_output.pop(0) for i in range(len(validate_dataset_output))]
container = try_swift_container_input("dummy")
if container:
try:
......@@ -223,12 +230,11 @@
except Exception as e:
validate_dataset_output.append(e)
validate_dataset_output.append("Your input dataset as specified cannot be used.")
else:
validate_dataset_output.append("You have to specify a valid configuration for the output swift container first!")
validate_dataset.disabled=False
validate_dataset.loading=False
toggle_button(validate_dataset)
return container
validate_dataset.on_click(try_dataset_input)
```
......@@ -305,14 +311,12 @@
# validate=False
# else :
# validate_writing.clicks = 0
# validate=True
start_writing.disabled=True
start_writing.loading=True
validate_writing.disabled=True
validate_writing.loading=True
toggle_button(start_writing)
toggle_button(validate_writing)
container = try_dataset_input("dummy")
if not container :
start_writing_output.append("First validate your dataset and container input.")
else:
......@@ -329,14 +333,12 @@
"`xarry.open_zarr('{0}', consolidated=True, decode_times=True)`".format(
url.value+"/"+container_name.value+"/"+zarr_dataset_name.value))
except Exception as e:
start_writing_output.append(e)
start_writing.disabled=False
start_writing.loading=False
validate_writing.disabled=False
validate_writing.loading=False
toggle_button(start_writing)
toggle_button(validate_writing)
start_writing.on_click(start_write_process)
validate_writing.on_click(start_validate_process)
```
......
Markdown is supported
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