Commit 5746b716 authored by Ivan Tyagov's avatar Ivan Tyagov

Fix double

See merge request nexedi/osie!37
parents b908384a f269aa86
......@@ -41,13 +41,12 @@
</UAVariable>
<!-- Double (float) example -->
<!-- <UAVariable NodeId="ns=1;i=5" BrowseName="1:erp5-variable-double" ParentNodeId="i=85" DataType="Doube" AccessLevel="3" UserAccessLevel="3">
<UAVariable NodeId="ns=1;i=5" BrowseName="1:erp5-variable-double" ParentNodeId="i=85" DataType="Double" AccessLevel="3" UserAccessLevel="3">
<DisplayName>erp5-variable-double</DisplayName>
<Description>erp5-variable-double</Description>
<References>
<Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=9</Reference>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
</References>
</UAVariable>-->
</UAVariable>
</UANodeSet>
......@@ -47,13 +47,23 @@ class ERP5Handler(asyncua.common.subscription.SubHandler):
if self.url is not None:
return f"%s/%s" %(self.url, ERP5_REQUEST_API)
def call(self, http_method = "POST", **data):
params = urllib.parse.quote_plus(json.dumps({k: str(v) for k, v in data.items()}))
def call(self, http_method="POST", **data):
serialized_data = {}
for k, v in data.items():
if not isinstance(v, (int, float, str)):
v = str(v)
serialized_data[k] = v
print(f"Key: {k}\nValue: {v}\nValue Type: {type(v)}\n\n")
params = urllib.parse.quote_plus(json.dumps(serialized_data))
self.session.auth = (erp5_username, erp5_password)
if http_method == "POST":
self.session.post(f"{self.uri}?data={params}")
self.session.post(f"{self.uri}?data={params}")
elif http_method == "GET":
return self.session.get(f"{self.uri}")
return self.session.get(f"{self.uri}")
def datachange_notification(self, node, val, data):
self.call(node=node, val=val, data=data)
......
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