forked from mirrors/thatmattlove-hyperglass
Fix query JSON serialization
This commit is contained in:
parent
e06ea5ecb9
commit
4792269168
3 changed files with 6 additions and 5 deletions
|
|
@ -90,7 +90,8 @@ class Construct:
|
|||
rules = [r for r in self.directive.rules if r._passed is True]
|
||||
if len(rules) < 1:
|
||||
raise InputInvalid(
|
||||
error="No validation rules matched target '{target}'", query=self.query
|
||||
error="No validation rules matched target '{target}'",
|
||||
target=self.query.query_target,
|
||||
)
|
||||
|
||||
for rule in [r for r in self.directive.rules if r._passed is True]:
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ async def execute(query: "Query") -> Union["OutputDataModel", str]:
|
|||
params = use_state("params")
|
||||
output = params.messages.general
|
||||
|
||||
log.debug("Received query {}", query.json())
|
||||
log.debug("Matched device config: {}", query.device)
|
||||
log.debug("Received query {}", query.export_dict())
|
||||
log.debug("Matched device config: {!s}", query.device)
|
||||
|
||||
mapped_driver = map_driver(query.device.driver)
|
||||
driver: "Connection" = mapped_driver(query.device, query)
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class Query(BaseModel):
|
|||
super().__init__(**kwargs)
|
||||
self.timestamp = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")
|
||||
state = use_state()
|
||||
self.state = state
|
||||
self._state = state
|
||||
try:
|
||||
self.validate_query_target()
|
||||
except InputValidationError as err:
|
||||
|
|
@ -117,7 +117,7 @@ class Query(BaseModel):
|
|||
@property
|
||||
def device(self) -> Device:
|
||||
"""Get this query's device object by query_location."""
|
||||
return self.state.devices[self.query_location]
|
||||
return self._state.devices[self.query_location]
|
||||
|
||||
@property
|
||||
def directive(self) -> Directive:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue