updated syncthing module
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Paul 2025-09-30 21:15:27 +02:00
parent a483cf7c74
commit 2b0b401c3a

View File

@ -27,7 +27,8 @@ def get_apikey(configfile="/root/.config/syncthing/config.xml"):
return None return None
def get_config(url="http://localhost:8384", verify=False, apikey=""):
def get_config(url="http://localhost:8384", verify=False, apikey=None):
try: try:
apikey = get_apikey() apikey = get_apikey()
except: except:
@ -47,7 +48,10 @@ def get_config(url="http://localhost:8384", verify=False, apikey=""):
return None return None
def set_config_options(url="http://localhost:8384", verify=False, apikey=get_apikey(), options={}):
def set_config_options(url="http://localhost:8384", verify=False, apikey=None, options={}):
if not apikey:
apikey = get_apikey()
fullurl = f"{url}/rest/config/options" fullurl = f"{url}/rest/config/options"
req = Request(method="PUT", req = Request(method="PUT",
url=fullurl, url=fullurl,
@ -68,7 +72,9 @@ def set_config_options(url="http://localhost:8384", verify=False, apikey=get_api
return None return None
def set_config_gui(url="http://localhost:8384", verify=False, apikey=get_apikey(), gui={}): def set_config_gui(url="http://localhost:8384", verify=False, apikey=None, gui={}):
if not apikey:
apikey = get_apikey()
fullurl = f"{url}/rest/config/gui" fullurl = f"{url}/rest/config/gui"
req = Request(method="PUT", req = Request(method="PUT",
url=fullurl, url=fullurl,
@ -92,7 +98,9 @@ def set_config_gui(url="http://localhost:8384", verify=False, apikey=get_apikey(
return None return None
## deprecated ## deprecated
def _set_config(url="http://localhost:8384", verify=False, apikey=get_apikey(), config={}): def _set_config(url="http://localhost:8384", verify=False, apikey=None, config={}):
if not apikey:
apikey = get_apikey()
fullurl = f"{url}/rest/config" fullurl = f"{url}/rest/config"
req = Request(method="POST", req = Request(method="POST",
url=fullurl, url=fullurl,
@ -113,7 +121,10 @@ def _set_config(url="http://localhost:8384", verify=False, apikey=get_apikey(),
return None return None
def insync(url="http://localhost:8384", verify=False, apikey=get_apikey()):
def insync(url="http://localhost:8384", verify=False, apikey=None):
if not apikey:
apikey = get_apikey()
fullurl = f"{url}/rest/config/restart-required" fullurl = f"{url}/rest/config/restart-required"
req = Request(method="GET", req = Request(method="GET",
url=fullurl) url=fullurl)
@ -128,7 +139,10 @@ def insync(url="http://localhost:8384", verify=False, apikey=get_apikey()):
return None return None
def restart(url="http://localhost:8384", verify=False, apikey=get_apikey()):
def restart(url="http://localhost:8384", verify=False, apikey=None):
if not apikey:
apikey = get_apikey()
fullurl = f"{url}/rest/system/restart" fullurl = f"{url}/rest/system/restart"
req = Request(method="POST", req = Request(method="POST",
url=fullurl) url=fullurl)