fix port
This commit is contained in:
31
SatiAPI.py
31
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.4.0'
|
__VERSION__ = '0.4.2'
|
||||||
|
|
||||||
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
|
||||||
@@ -149,7 +149,7 @@ class SatiAPI:
|
|||||||
:type query: string
|
:type query: string
|
||||||
:param data: (maybe optional) data to be send as dict
|
:param data: (maybe optional) data to be send as dict
|
||||||
:type data: dict
|
:type data: dict
|
||||||
:return: response from server striped from "data" wrapper or False
|
:return: response from server
|
||||||
:rtype: dict | None | bool
|
:rtype: dict | None | bool
|
||||||
"""
|
"""
|
||||||
payload = dict()
|
payload = dict()
|
||||||
@@ -163,7 +163,7 @@ class SatiAPI:
|
|||||||
if self.token is not None:
|
if self.token is not None:
|
||||||
headers['Authorization'] = f'Bearer {self.token}'
|
headers['Authorization'] = f'Bearer {self.token}'
|
||||||
|
|
||||||
response = requests.post(f'https://{self.host}:7777/api/v1', headers=headers, json=payload, verify=False)
|
response = requests.post(f'https://{self.host}:{self.port}/api/v1', headers=headers, json=payload, verify=False)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
json_response = json.loads(response.text)
|
json_response = json.loads(response.text)
|
||||||
if 'data' in json_response:
|
if 'data' in json_response:
|
||||||
@@ -255,10 +255,33 @@ class SatiAPI:
|
|||||||
:rtpye: dict
|
:rtpye: dict
|
||||||
"""
|
"""
|
||||||
return self.__query('GetAdvancedGameSettings')
|
return self.__query('GetAdvancedGameSettings')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## todo
|
## todo
|
||||||
#PasswordlessLogin
|
#PasswordlessLogin
|
||||||
|
#ClaimServer
|
||||||
|
#RenameServer
|
||||||
|
#SetClientPassword
|
||||||
|
#SetAdminPassword
|
||||||
|
#SetAutoLoadSessionName
|
||||||
|
#ApplyServerOptions
|
||||||
|
#ApplyAdvancedGameSettings
|
||||||
|
#RunCommand
|
||||||
|
#Shutdown
|
||||||
|
#CreateNewGame
|
||||||
|
#SaveGame
|
||||||
|
#DeleteSaveFile
|
||||||
|
#DeleteSaveSession
|
||||||
|
#EnumerateSessions
|
||||||
|
#LoadGame
|
||||||
|
#UploadSaveGame
|
||||||
|
#DownloadSaveGame
|
||||||
|
|
||||||
if __name__ == "__main__":
|
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_advanced_game_settings())
|
print(sati.get_status())
|
||||||
|
# print(sati.get_advanced_game_settings())
|
||||||
Reference in New Issue
Block a user