瀏覽代碼

Add invalid query status text

Arkadiusz Ryś 2 年之前
父節點
當前提交
397a8f00dc

+ 1 - 1
graph_exploring_tool/graphical/interface.py

@@ -4,7 +4,6 @@ from typing import List
 
 import arklog
 import dearpygui.dearpygui as dpg
-from dearpygui import demo
 
 from graph_exploring_tool.configuration import Configuration
 from graph_exploring_tool.graphical.constants import PRIMARY_WINDOW_TAG, MAIN_QUERY_GROUP_TAG, MAIN_DIAGRAM_GROUP_TAG
@@ -39,6 +38,7 @@ def interface(configuration: Configuration, palette: List[QueryTemplate], width=
         add_main_menu()
         create_query_group(configuration, palette)
         create_diagram_group()
+    # from dearpygui import demo
     # demo.show_demo()
     dpg.setup_dearpygui()
     dpg.show_viewport()

+ 8 - 1
graph_exploring_tool/graphical/query_group.py

@@ -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:

+ 1 - 1
graph_exploring_tool/main.py

@@ -21,7 +21,7 @@ def handler(signal_code, _) -> None:
 
 
 def load_palette(palette_directory: Path) -> List:
-    """"""
+    """Grab all the toml files in the palette directory and load them into memory."""
     for query_path in palette_directory.rglob("*.toml"):
         logging.debug(f"Loading palette query '{query_path}'.")
         query_configuration = toml.loads(query_path.read_text(encoding="utf-8"))

+ 2 - 0
graph_exploring_tool/query.py

@@ -72,6 +72,8 @@ reverse_prefix = {
     "http://ua.be/sdo2l/vocabulary/formalisms/traceability_model#": "traceability_model",
     "http://ua.be/sdo2l/vocabulary/formalisms/xopp#": "xopp",
     "http://ua.be/sdo2l/vocabulary/federation#": "federation",
+
+    "http://ua.be/sdo2l/description/artifacts/FTG_ftg#": "artifacts_ftg",
 }