|
@@ -1,5 +1,6 @@
|
|
|
import enum
|
|
|
import logging
|
|
|
+import urllib
|
|
|
from itertools import groupby
|
|
|
from typing import List, Union, Optional
|
|
|
from urllib.error import URLError
|
|
@@ -88,7 +89,7 @@ def create_query_palette(query_palette: List[QueryTemplate]):
|
|
|
def create_query_options(endpoint: str):
|
|
|
with dpg.group(horizontal=True):
|
|
|
dpg.add_combo(("Visual", "Textual"), default_value="Visual", callback=_mode_select, width=100, tag=EDITOR_SELECTOR_TAG)
|
|
|
- dpg.add_input_text(default_value=endpoint, width=300, enabled=False, tag=ENDPOINT_TEXTINPUT_TAG)
|
|
|
+ dpg.add_input_text(default_value=endpoint, width=500, enabled=True, tag=ENDPOINT_TEXTINPUT_TAG)
|
|
|
dpg.add_checkbox(label="debug", callback=_config)
|
|
|
dpg.add_checkbox(label="annotate", default_value=False, callback=_config) # TODO Actually make this annotate the result data with its type
|
|
|
|
|
@@ -217,8 +218,14 @@ def _perform_query(sender: int, mode: str, user_data: Optional[dict]):
|
|
|
placeholder = dpg.get_item_user_data(replacement_field).placeholder
|
|
|
query_text = query_text.replace(f"{{{{ {placeholder} }}}}", value)
|
|
|
query_result = query.perform_query(endpoint, prefix_text + "\n" + query_text, use_post_method)
|
|
|
+ except urllib.error.HTTPError as e:
|
|
|
+ logging.exception(e)
|
|
|
+ if e.code in [400]:
|
|
|
+ set_status_text(f"Invalid query.", StatusMessageType.ERROR)
|
|
|
+ return
|
|
|
except URLError as e:
|
|
|
logging.error(f"Connection to '{endpoint}' failed.")
|
|
|
+ logging.exception(e)
|
|
|
set_status_text(f"Connection to '{endpoint}' failed.", StatusMessageType.ERROR)
|
|
|
return
|
|
|
if use_post_method:
|