Merge pull request #285 from ivanpavlina/master

Support for additional attributes on execute
This commit is contained in:
Tomaae 2023-05-31 16:44:08 +02:00 committed by GitHub
commit 4d957aec22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View file

@ -387,9 +387,9 @@ class MikrotikControllerData:
# ---------------------------
# execute
# ---------------------------
def execute(self, path, command, param, value):
def execute(self, path, command, param, value, attributes=None):
"""Change value using Mikrotik API"""
return self.api.execute(path, command, param, value)
return self.api.execute(path, command, param, value, attributes)
# ---------------------------
# run_script
@ -1544,7 +1544,9 @@ class MikrotikControllerData:
):
return
self.execute("/system/package/update", "check-for-updates", None, None)
self.execute(
"/system/package/update", "check-for-updates", None, None, {"duration": 10}
)
self.data["fw-update"] = parse_api(
data=self.data["fw-update"],
source=self.api.query("/system/package/update"),

View file

@ -258,7 +258,7 @@ class MikrotikAPI:
# ---------------------------
# execute
# ---------------------------
def execute(self, path, command, param, value) -> bool:
def execute(self, path, command, param, value, attributes=None) -> bool:
"""Execute a command"""
entry_found = None
params = {}
@ -292,6 +292,9 @@ class MikrotikAPI:
params = {".id": entry_found}
if attributes:
params.update(attributes)
self.lock.acquire()
try:
tuple(response(command, **params))