add shutdown
This commit is contained in:
16
SatiAPI.py
16
SatiAPI.py
@@ -16,7 +16,7 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|||||||
class SatiAPI:
|
class SatiAPI:
|
||||||
"""A API wrapper for Satisfactory dedicated server"""
|
"""A API wrapper for Satisfactory dedicated server"""
|
||||||
__AUTHOR__ = 'anima'
|
__AUTHOR__ = 'anima'
|
||||||
__VERSION__ = '0.10.1'
|
__VERSION__ = '0.11.0'
|
||||||
|
|
||||||
def __init__(self, host: str = None, port: int = 7777, token: str = None, conffile: str = 'conf.yml', logfile: str = 'SatiAPI.log', loglevel: int = 20) -> None:
|
def __init__(self, host: str = None, port: int = 7777, token: str = None, conffile: str = 'conf.yml', logfile: str = 'SatiAPI.log', loglevel: int = 20) -> None:
|
||||||
"""create a wrapper for satisfactory dedicated server
|
"""create a wrapper for satisfactory dedicated server
|
||||||
@@ -198,7 +198,8 @@ class SatiAPI:
|
|||||||
self._log.error(f'wrong response data {json_response=}')
|
self._log.error(f'wrong response data {json_response=}')
|
||||||
|
|
||||||
elif response.status_code == 204:
|
elif response.status_code == 204:
|
||||||
# response from rename server
|
# response from rename server, shutdown ...
|
||||||
|
print(query)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -297,6 +298,14 @@ class SatiAPI:
|
|||||||
response = self.__query('PasswordLogin', data)
|
response = self.__query('PasswordLogin', data)
|
||||||
return self._save_token(response)
|
return self._save_token(response)
|
||||||
|
|
||||||
|
def shutdown(self) -> bool:
|
||||||
|
"""Shuts down the Dedicated Server. If automatic restart script is setup, this allows restarting the server to apply new settings or update. Requires Admin privileges. Shutdowns initiated by remote hosts are logged with their IP and their token. Function does not return any data on success, and does not take any parameters.
|
||||||
|
|
||||||
|
:return: true is shutdown successfull init
|
||||||
|
:rtype: bool
|
||||||
|
"""
|
||||||
|
return self.__query('Shutdown', auth=True)
|
||||||
|
|
||||||
def set_admin_password(self, password: str = None):
|
def set_admin_password(self, password: str = None):
|
||||||
"""Updates the currently set Admin Password. This will invalidate all previously issued Client and Admin authentication tokens. Requires Admin privileges. Function does not return any data on success.
|
"""Updates the currently set Admin Password. This will invalidate all previously issued Client and Admin authentication tokens. Requires Admin privileges. Function does not return any data on success.
|
||||||
|
|
||||||
@@ -397,7 +406,6 @@ class SatiAPI:
|
|||||||
|
|
||||||
## todo
|
## todo
|
||||||
#RunCommand
|
#RunCommand
|
||||||
#Shutdown
|
|
||||||
|
|
||||||
#SetAutoLoadSessionName
|
#SetAutoLoadSessionName
|
||||||
#ApplyServerOptions
|
#ApplyServerOptions
|
||||||
@@ -418,4 +426,4 @@ if __name__ == "__main__":
|
|||||||
sati = SatiAPI(loglevel=10)
|
sati = SatiAPI(loglevel=10)
|
||||||
# print('Verbundene Spieler: ', sati.get_status()['serverGameState']['numConnectedPlayers'])
|
# print('Verbundene Spieler: ', sati.get_status()['serverGameState']['numConnectedPlayers'])
|
||||||
print(sati.get_status())
|
print(sati.get_status())
|
||||||
print(sati.set_servername('OtherName'))
|
print(sati.shutdown())
|
||||||
Reference in New Issue
Block a user