23
SatiAPI.py
23
SatiAPI.py
@@ -16,7 +16,7 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
class SatiAPI:
|
||||
"""A API wrapper for Satisfactory dedicated server"""
|
||||
__AUTHOR__ = 'anima'
|
||||
__VERSION__ = '0.11.0'
|
||||
__VERSION__ = '0.11.3'
|
||||
|
||||
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
|
||||
@@ -196,10 +196,17 @@ class SatiAPI:
|
||||
# self._log.debug(f'token expired')
|
||||
# self.get_token()
|
||||
self._log.error(f'wrong response data {json_response=}')
|
||||
elif response.status_code == 201:
|
||||
# The function has been executed and returned no error. Returned by some functions to indicate that a new file has been created, such as UploadSaveGame
|
||||
return True
|
||||
|
||||
elif response.status_code == 202:
|
||||
# The function has been executed, but is still being processed. This is returned by some functions with side deffects, such as LoadGame
|
||||
return True
|
||||
|
||||
elif response.status_code == 204:
|
||||
# response from rename server, shutdown ...
|
||||
print(query)
|
||||
# used from some querys as response with no response content
|
||||
# The function has been executed successfully, but returned no data (and no error)
|
||||
return True
|
||||
|
||||
else:
|
||||
@@ -386,6 +393,14 @@ class SatiAPI:
|
||||
|
||||
return self.__query('HealthCheck', data)
|
||||
|
||||
def get_sessions(self):
|
||||
return self.__query('EnumerateSessions', auth=True)
|
||||
|
||||
# def create_new_game(self, sessionname, startlocation) -> bool:
|
||||
# data = dict()
|
||||
# data['NewGameData']
|
||||
# pass
|
||||
|
||||
def get_server_options(self) -> dict:
|
||||
"""Retrieves currently applied server options and server options that are still pending application (because of needing session or server restart) Does not require input parameters.
|
||||
|
||||
@@ -426,4 +441,4 @@ if __name__ == "__main__":
|
||||
sati = SatiAPI(loglevel=10)
|
||||
# print('Verbundene Spieler: ', sati.get_status()['serverGameState']['numConnectedPlayers'])
|
||||
print(sati.get_status())
|
||||
print(sati.shutdown())
|
||||
print(sati.get_sessions())
|
||||
Reference in New Issue
Block a user