added attributes to execute method, using it on check-for-updates. hardcoded 10 seconds for duration

This commit is contained in:
Ivan Pavlina 2023-05-31 06:56:50 +00:00
parent 251874bdc2
commit 22844e7ae5
2 changed files with 7 additions and 4 deletions

View file

@ -387,9 +387,9 @@ class MikrotikControllerData:
# --------------------------- # ---------------------------
# execute # execute
# --------------------------- # ---------------------------
def execute(self, path, command, param, value): def execute(self, path, command, param, value, attributes=None):
"""Change value using Mikrotik API""" """Change value using Mikrotik API"""
return self.api.execute(path, command, param, value) return self.api.execute(path, command, param, value, attributes)
# --------------------------- # ---------------------------
# run_script # run_script
@ -1544,7 +1544,7 @@ class MikrotikControllerData:
): ):
return 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( self.data["fw-update"] = parse_api(
data=self.data["fw-update"], data=self.data["fw-update"],
source=self.api.query("/system/package/update"), source=self.api.query("/system/package/update"),

View file

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