Fix minor bugs of get_terminal output caused by a11y tree depth
This commit is contained in:
@@ -17,10 +17,16 @@ from .utils import _match_record, _match_value_to_rule
|
|||||||
|
|
||||||
|
|
||||||
def check_include_exclude(result: str, rules: Dict[str, List[str]]) -> float:
|
def check_include_exclude(result: str, rules: Dict[str, List[str]]) -> float:
|
||||||
|
if result is None:
|
||||||
|
return 0.
|
||||||
|
|
||||||
print(result, rules)
|
print(result, rules)
|
||||||
include = rules.get("include", [])
|
include = rules.get("include", [])
|
||||||
exclude = rules.get("exclude", [])
|
exclude = rules.get("exclude", [])
|
||||||
return all(r in result for r in include) and all(r not in result for r in exclude)
|
if all(r in result for r in include) and all(r not in result for r in exclude):
|
||||||
|
return 1.
|
||||||
|
else:
|
||||||
|
return 0.
|
||||||
|
|
||||||
|
|
||||||
def exact_match(result, rules) -> float:
|
def exact_match(result, rules) -> float:
|
||||||
|
|||||||
@@ -176,8 +176,9 @@ def get_terminal_output():
|
|||||||
# raise NotImplementedError
|
# raise NotImplementedError
|
||||||
return "Currently not implemented for platform {:}.".format(platform.platform()), 500
|
return "Currently not implemented for platform {:}.".format(platform.platform()), 500
|
||||||
return jsonify({"output": output, "status": "success"})
|
return jsonify({"output": output, "status": "success"})
|
||||||
except:
|
except Exception as e:
|
||||||
return jsonify({"output": None, "status": "error"})
|
logger.error("Failed to get terminal output. Error: %s", e)
|
||||||
|
return jsonify({"status": "error", "message": str(e)}), 500
|
||||||
|
|
||||||
|
|
||||||
_accessibility_ns_map = {"st": "uri:deskat:state.at-spi.gnome.org"
|
_accessibility_ns_map = {"st": "uri:deskat:state.at-spi.gnome.org"
|
||||||
@@ -191,7 +192,7 @@ _accessibility_ns_map = {"st": "uri:deskat:state.at-spi.gnome.org"
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _create_atspi_node(node: Accessible, depth: int, flag: Optional[str] = None) -> _Element:
|
def _create_atspi_node(node: Accessible, depth: int = 0, flag: Optional[str] = None) -> _Element:
|
||||||
if node.getRoleName() == "document spreadsheet":
|
if node.getRoleName() == "document spreadsheet":
|
||||||
flag = "calc"
|
flag = "calc"
|
||||||
if node.getRoleName() == "application" and node.name=="Thunderbird":
|
if node.getRoleName() == "application" and node.name=="Thunderbird":
|
||||||
|
|||||||
Reference in New Issue
Block a user