AutoPEP8 formatting
This commit is contained in:
parent
b79efb22d4
commit
9ba4230745
11 changed files with 3 additions and 106 deletions
3
Makefile
3
Makefile
|
@ -14,3 +14,6 @@ clean:
|
||||||
check:
|
check:
|
||||||
chmod +x test.sh
|
chmod +x test.sh
|
||||||
bash test.sh
|
bash test.sh
|
||||||
|
|
||||||
|
format:
|
||||||
|
python -m autopep8 -r --in-place .
|
||||||
|
|
|
@ -27,7 +27,6 @@ class Client:
|
||||||
self,
|
self,
|
||||||
atconn: AternosConnect,
|
atconn: AternosConnect,
|
||||||
servers: Optional[List[str]] = None) -> None:
|
servers: Optional[List[str]] = None) -> None:
|
||||||
|
|
||||||
"""Aternos API Client class, object
|
"""Aternos API Client class, object
|
||||||
of which contains user's auth data
|
of which contains user's auth data
|
||||||
|
|
||||||
|
@ -56,7 +55,6 @@ class Client:
|
||||||
code: Optional[int] = None,
|
code: Optional[int] = None,
|
||||||
sessions_dir: str = '~',
|
sessions_dir: str = '~',
|
||||||
**custom_args):
|
**custom_args):
|
||||||
|
|
||||||
"""Log in to an Aternos account with
|
"""Log in to an Aternos account with
|
||||||
a username and a hashed password
|
a username and a hashed password
|
||||||
|
|
||||||
|
@ -132,7 +130,6 @@ class Client:
|
||||||
code: Optional[int] = None,
|
code: Optional[int] = None,
|
||||||
sessions_dir: str = '~',
|
sessions_dir: str = '~',
|
||||||
**custom_args):
|
**custom_args):
|
||||||
|
|
||||||
"""Log in to Aternos with a username and a plain password
|
"""Log in to Aternos with a username and a plain password
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -157,7 +154,6 @@ class Client:
|
||||||
session: str,
|
session: str,
|
||||||
servers: Optional[List[str]] = None,
|
servers: Optional[List[str]] = None,
|
||||||
**custom_args):
|
**custom_args):
|
||||||
|
|
||||||
"""Log in to Aternos using a session cookie value
|
"""Log in to Aternos using a session cookie value
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -181,7 +177,6 @@ class Client:
|
||||||
cls,
|
cls,
|
||||||
file: str = '~/.aternos',
|
file: str = '~/.aternos',
|
||||||
**custom_args):
|
**custom_args):
|
||||||
|
|
||||||
"""Log in to Aternos using
|
"""Log in to Aternos using
|
||||||
a saved ATERNOS_SESSION cookie
|
a saved ATERNOS_SESSION cookie
|
||||||
|
|
||||||
|
@ -228,7 +223,6 @@ class Client:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def md5encode(passwd: str) -> str:
|
def md5encode(passwd: str) -> str:
|
||||||
|
|
||||||
"""Encodes the given string with MD5
|
"""Encodes the given string with MD5
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -243,7 +237,6 @@ class Client:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def session_file(username: str, sessions_dir: str = '~') -> str:
|
def session_file(username: str, sessions_dir: str = '~') -> str:
|
||||||
|
|
||||||
"""Generates session file name
|
"""Generates session file name
|
||||||
for authenticated user
|
for authenticated user
|
||||||
|
|
||||||
|
@ -270,7 +263,6 @@ class Client:
|
||||||
self,
|
self,
|
||||||
file: str = '~/.aternos',
|
file: str = '~/.aternos',
|
||||||
incl_servers: bool = True) -> None:
|
incl_servers: bool = True) -> None:
|
||||||
|
|
||||||
"""Saves an ATERNOS_SESSION cookie to a file
|
"""Saves an ATERNOS_SESSION cookie to a file
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -293,7 +285,6 @@ class Client:
|
||||||
f.write(s.servid + '\n')
|
f.write(s.servid + '\n')
|
||||||
|
|
||||||
def remove_session(self, file: str = '~/.aternos') -> None:
|
def remove_session(self, file: str = '~/.aternos') -> None:
|
||||||
|
|
||||||
"""Removes a file which contains
|
"""Removes a file which contains
|
||||||
ATERNOS_SESSION cookie saved
|
ATERNOS_SESSION cookie saved
|
||||||
with `save_session()`
|
with `save_session()`
|
||||||
|
@ -311,7 +302,6 @@ class Client:
|
||||||
logging.warning('Unable to delete session file: %s', err)
|
logging.warning('Unable to delete session file: %s', err)
|
||||||
|
|
||||||
def list_servers(self, cache: bool = True) -> List[AternosServer]:
|
def list_servers(self, cache: bool = True) -> List[AternosServer]:
|
||||||
|
|
||||||
"""Parses a list of your servers from Aternos website
|
"""Parses a list of your servers from Aternos website
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -344,7 +334,6 @@ class Client:
|
||||||
return self.servers
|
return self.servers
|
||||||
|
|
||||||
def refresh_servers(self, ids: List[str]) -> None:
|
def refresh_servers(self, ids: List[str]) -> None:
|
||||||
|
|
||||||
"""Replaces cached servers list creating
|
"""Replaces cached servers list creating
|
||||||
AternosServer objects by given IDs
|
AternosServer objects by given IDs
|
||||||
|
|
||||||
|
@ -366,7 +355,6 @@ class Client:
|
||||||
self.parsed = True
|
self.parsed = True
|
||||||
|
|
||||||
def get_server(self, servid: str) -> AternosServer:
|
def get_server(self, servid: str) -> AternosServer:
|
||||||
|
|
||||||
"""Creates a server object from the server ID.
|
"""Creates a server object from the server ID.
|
||||||
Use this instead of list_servers
|
Use this instead of list_servers
|
||||||
if you know the ID to save some time.
|
if you know the ID to save some time.
|
||||||
|
@ -378,7 +366,6 @@ class Client:
|
||||||
return AternosServer(servid, self.atconn)
|
return AternosServer(servid, self.atconn)
|
||||||
|
|
||||||
def logout(self) -> None:
|
def logout(self) -> None:
|
||||||
|
|
||||||
"""Log out from Aternos account"""
|
"""Log out from Aternos account"""
|
||||||
|
|
||||||
self.atconn.request_cloudflare(
|
self.atconn.request_cloudflare(
|
||||||
|
@ -389,7 +376,6 @@ class Client:
|
||||||
self.remove_session(self.saved_session)
|
self.remove_session(self.saved_session)
|
||||||
|
|
||||||
def change_username(self, value: str) -> None:
|
def change_username(self, value: str) -> None:
|
||||||
|
|
||||||
"""Changes a username in your Aternos account
|
"""Changes a username in your Aternos account
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -402,7 +388,6 @@ class Client:
|
||||||
)
|
)
|
||||||
|
|
||||||
def change_email(self, value: str) -> None:
|
def change_email(self, value: str) -> None:
|
||||||
|
|
||||||
"""Changes an e-mail in your Aternos account
|
"""Changes an e-mail in your Aternos account
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -425,7 +410,6 @@ class Client:
|
||||||
)
|
)
|
||||||
|
|
||||||
def change_password(self, old: str, new: str) -> None:
|
def change_password(self, old: str, new: str) -> None:
|
||||||
|
|
||||||
"""Changes a password in your Aternos account
|
"""Changes a password in your Aternos account
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -439,7 +423,6 @@ class Client:
|
||||||
)
|
)
|
||||||
|
|
||||||
def change_password_hashed(self, old: str, new: str) -> None:
|
def change_password_hashed(self, old: str, new: str) -> None:
|
||||||
|
|
||||||
"""Changes a password in your Aternos account.
|
"""Changes a password in your Aternos account.
|
||||||
Unlike `change_password`, this function
|
Unlike `change_password`, this function
|
||||||
takes hashed passwords as arguments
|
takes hashed passwords as arguments
|
||||||
|
@ -458,7 +441,6 @@ class Client:
|
||||||
)
|
)
|
||||||
|
|
||||||
def qrcode_2fa(self) -> Dict[str, str]:
|
def qrcode_2fa(self) -> Dict[str, str]:
|
||||||
|
|
||||||
"""Requests a secret code and
|
"""Requests a secret code and
|
||||||
a QR code for enabling 2FA"""
|
a QR code for enabling 2FA"""
|
||||||
|
|
||||||
|
@ -468,7 +450,6 @@ class Client:
|
||||||
).json()
|
).json()
|
||||||
|
|
||||||
def save_qr(self, qrcode: str, filename: str) -> None:
|
def save_qr(self, qrcode: str, filename: str) -> None:
|
||||||
|
|
||||||
"""Writes a 2FA QR code into a png-file
|
"""Writes a 2FA QR code into a png-file
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -484,7 +465,6 @@ class Client:
|
||||||
f.write(png)
|
f.write(png)
|
||||||
|
|
||||||
def enable_2fa(self, code: int) -> None:
|
def enable_2fa(self, code: int) -> None:
|
||||||
|
|
||||||
"""Enables Two-Factor Authentication
|
"""Enables Two-Factor Authentication
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -499,7 +479,6 @@ class Client:
|
||||||
)
|
)
|
||||||
|
|
||||||
def disable_2fa(self, code: int) -> None:
|
def disable_2fa(self, code: int) -> None:
|
||||||
|
|
||||||
"""Disables Two-Factor Authentication
|
"""Disables Two-Factor Authentication
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|
|
@ -124,7 +124,6 @@ class AternosConfig:
|
||||||
"""Class for editing server settings"""
|
"""Class for editing server settings"""
|
||||||
|
|
||||||
def __init__(self, atserv: 'AternosServer') -> None:
|
def __init__(self, atserv: 'AternosServer') -> None:
|
||||||
|
|
||||||
"""Class for editing server settings
|
"""Class for editing server settings
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -135,7 +134,6 @@ class AternosConfig:
|
||||||
self.atserv = atserv
|
self.atserv = atserv
|
||||||
|
|
||||||
def get_timezone(self) -> str:
|
def get_timezone(self) -> str:
|
||||||
|
|
||||||
"""Parses timezone from options page
|
"""Parses timezone from options page
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -154,7 +152,6 @@ class AternosConfig:
|
||||||
return tztext.strip()
|
return tztext.strip()
|
||||||
|
|
||||||
def set_timezone(self, value: str) -> None:
|
def set_timezone(self, value: str) -> None:
|
||||||
|
|
||||||
"""Sets new timezone
|
"""Sets new timezone
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -178,7 +175,6 @@ class AternosConfig:
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_java(self) -> int:
|
def get_java(self) -> int:
|
||||||
|
|
||||||
"""Parses Java version from options page
|
"""Parses Java version from options page
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -200,7 +196,6 @@ class AternosConfig:
|
||||||
return int(jdkver)
|
return int(jdkver)
|
||||||
|
|
||||||
def set_java(self, value: int) -> None:
|
def set_java(self, value: int) -> None:
|
||||||
|
|
||||||
"""Sets new Java version
|
"""Sets new Java version
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -217,7 +212,6 @@ class AternosConfig:
|
||||||
# server.properties
|
# server.properties
|
||||||
#
|
#
|
||||||
def set_server_prop(self, option: str, value: Any) -> None:
|
def set_server_prop(self, option: str, value: Any) -> None:
|
||||||
|
|
||||||
"""Sets server.properties option
|
"""Sets server.properties option
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -231,7 +225,6 @@ class AternosConfig:
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_server_props(self, proptyping: bool = True) -> Dict[str, Any]:
|
def get_server_props(self, proptyping: bool = True) -> Dict[str, Any]:
|
||||||
|
|
||||||
"""Parses all server.properties from options page
|
"""Parses all server.properties from options page
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -248,7 +241,6 @@ class AternosConfig:
|
||||||
return self.__get_all_props('https://aternos.org/options', proptyping)
|
return self.__get_all_props('https://aternos.org/options', proptyping)
|
||||||
|
|
||||||
def set_server_props(self, props: Dict[str, Any]) -> None:
|
def set_server_props(self, props: Dict[str, Any]) -> None:
|
||||||
|
|
||||||
"""Updates server.properties options with the given dict
|
"""Updates server.properties options with the given dict
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -266,7 +258,6 @@ class AternosConfig:
|
||||||
self, option: Union[WorldOpts, WorldRules],
|
self, option: Union[WorldOpts, WorldRules],
|
||||||
value: Any, gamerule: bool = False,
|
value: Any, gamerule: bool = False,
|
||||||
world: str = 'world') -> None:
|
world: str = 'world') -> None:
|
||||||
|
|
||||||
"""Sets level.dat option for specified world
|
"""Sets level.dat option for specified world
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -290,7 +281,6 @@ class AternosConfig:
|
||||||
def get_world_props(
|
def get_world_props(
|
||||||
self, world: str = 'world',
|
self, world: str = 'world',
|
||||||
proptyping: bool = True) -> Dict[str, Any]:
|
proptyping: bool = True) -> Dict[str, Any]:
|
||||||
|
|
||||||
"""Parses level.dat from specified world's options page
|
"""Parses level.dat from specified world's options page
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -314,7 +304,6 @@ class AternosConfig:
|
||||||
self,
|
self,
|
||||||
props: Dict[Union[WorldOpts, WorldRules], Any],
|
props: Dict[Union[WorldOpts, WorldRules], Any],
|
||||||
world: str = 'world') -> None:
|
world: str = 'world') -> None:
|
||||||
|
|
||||||
"""Sets level.dat options from
|
"""Sets level.dat options from
|
||||||
the dictionary for the specified world
|
the dictionary for the specified world
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@ class AternosConnect:
|
||||||
self.token = ''
|
self.token = ''
|
||||||
|
|
||||||
def add_args(self, **kwargs) -> None:
|
def add_args(self, **kwargs) -> None:
|
||||||
|
|
||||||
"""Pass arguments to CloudScarper
|
"""Pass arguments to CloudScarper
|
||||||
session object __init__
|
session object __init__
|
||||||
if kwargs is not empty
|
if kwargs is not empty
|
||||||
|
@ -59,7 +58,6 @@ class AternosConnect:
|
||||||
self.refresh_session()
|
self.refresh_session()
|
||||||
|
|
||||||
def clear_args(self) -> None:
|
def clear_args(self) -> None:
|
||||||
|
|
||||||
"""Clear CloudScarper object __init__ arguments
|
"""Clear CloudScarper object __init__ arguments
|
||||||
which was set using add_args method"""
|
which was set using add_args method"""
|
||||||
|
|
||||||
|
@ -68,7 +66,6 @@ class AternosConnect:
|
||||||
self.refresh_session()
|
self.refresh_session()
|
||||||
|
|
||||||
def refresh_session(self) -> None:
|
def refresh_session(self) -> None:
|
||||||
|
|
||||||
"""Creates a new CloudScraper
|
"""Creates a new CloudScraper
|
||||||
session object and copies all cookies.
|
session object and copies all cookies.
|
||||||
Required for bypassing Cloudflare"""
|
Required for bypassing Cloudflare"""
|
||||||
|
@ -79,7 +76,6 @@ class AternosConnect:
|
||||||
del old_cookies
|
del old_cookies
|
||||||
|
|
||||||
def parse_token(self) -> str:
|
def parse_token(self) -> str:
|
||||||
|
|
||||||
"""Parses Aternos ajax token that
|
"""Parses Aternos ajax token that
|
||||||
is needed for most requests
|
is needed for most requests
|
||||||
|
|
||||||
|
@ -149,7 +145,6 @@ class AternosConnect:
|
||||||
return self.token
|
return self.token
|
||||||
|
|
||||||
def generate_sec(self) -> str:
|
def generate_sec(self) -> str:
|
||||||
|
|
||||||
"""Generates Aternos SEC token which
|
"""Generates Aternos SEC token which
|
||||||
is also needed for most API requests
|
is also needed for most API requests
|
||||||
|
|
||||||
|
@ -175,7 +170,6 @@ class AternosConnect:
|
||||||
reqcookies: Optional[Dict[Any, Any]] = None,
|
reqcookies: Optional[Dict[Any, Any]] = None,
|
||||||
sendtoken: bool = False,
|
sendtoken: bool = False,
|
||||||
retry: int = 5) -> requests.Response:
|
retry: int = 5) -> requests.Response:
|
||||||
|
|
||||||
"""Sends a request to Aternos API bypass Cloudflare
|
"""Sends a request to Aternos API bypass Cloudflare
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -287,7 +281,6 @@ class AternosConnect:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def atsession(self) -> str:
|
def atsession(self) -> str:
|
||||||
|
|
||||||
"""Aternos session cookie,
|
"""Aternos session cookie,
|
||||||
empty string if not logged in
|
empty string if not logged in
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ class ServerError(AternosError):
|
||||||
"""Common class for server errors"""
|
"""Common class for server errors"""
|
||||||
|
|
||||||
def __init__(self, reason: str, message: str = '') -> None:
|
def __init__(self, reason: str, message: str = '') -> None:
|
||||||
|
|
||||||
"""Common class for server errors
|
"""Common class for server errors
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -71,7 +70,6 @@ class ServerStartError(AternosError):
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, reason: str) -> None:
|
def __init__(self, reason: str) -> None:
|
||||||
|
|
||||||
"""Raised when Aternos
|
"""Raised when Aternos
|
||||||
can not start Minecraft server
|
can not start Minecraft server
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ class AternosFile:
|
||||||
dlable: bool, editable: bool,
|
dlable: bool, editable: bool,
|
||||||
ftype: FileType = FileType.file,
|
ftype: FileType = FileType.file,
|
||||||
size: Union[int, float] = 0) -> None:
|
size: Union[int, float] = 0) -> None:
|
||||||
|
|
||||||
"""File class which contains info
|
"""File class which contains info
|
||||||
about its path, type and size
|
about its path, type and size
|
||||||
|
|
||||||
|
@ -68,7 +67,6 @@ class AternosFile:
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
ftype: FileType = FileType.file) -> None:
|
ftype: FileType = FileType.file) -> None:
|
||||||
|
|
||||||
"""Creates a file or a directory inside this one
|
"""Creates a file or a directory inside this one
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -102,7 +100,6 @@ class AternosFile:
|
||||||
raise FileError('Unable to create a file')
|
raise FileError('Unable to create a file')
|
||||||
|
|
||||||
def delete(self) -> None:
|
def delete(self) -> None:
|
||||||
|
|
||||||
"""Deletes the file
|
"""Deletes the file
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
|
@ -126,7 +123,6 @@ class AternosFile:
|
||||||
raise FileError('Unable to delete the file')
|
raise FileError('Unable to delete the file')
|
||||||
|
|
||||||
def get_content(self) -> bytes:
|
def get_content(self) -> bytes:
|
||||||
|
|
||||||
"""Requests file content in bytes (downloads it)
|
"""Requests file content in bytes (downloads it)
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
|
@ -159,7 +155,6 @@ class AternosFile:
|
||||||
return file.content
|
return file.content
|
||||||
|
|
||||||
def set_content(self, value: bytes) -> None:
|
def set_content(self, value: bytes) -> None:
|
||||||
|
|
||||||
"""Modifies file content
|
"""Modifies file content
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -181,7 +176,6 @@ class AternosFile:
|
||||||
raise FileError('Unable to save the file')
|
raise FileError('Unable to save the file')
|
||||||
|
|
||||||
def get_text(self) -> str:
|
def get_text(self) -> str:
|
||||||
|
|
||||||
"""Requests editing the file as a text
|
"""Requests editing the file as a text
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
|
@ -220,7 +214,6 @@ class AternosFile:
|
||||||
return editblock[0].text_content()
|
return editblock[0].text_content()
|
||||||
|
|
||||||
def set_text(self, value: str) -> None:
|
def set_text(self, value: str) -> None:
|
||||||
|
|
||||||
"""Modifies the file content,
|
"""Modifies the file content,
|
||||||
but unlike `set_content` takes
|
but unlike `set_content` takes
|
||||||
a string as an argument
|
a string as an argument
|
||||||
|
@ -233,7 +226,6 @@ class AternosFile:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path(self) -> str:
|
def path(self) -> str:
|
||||||
|
|
||||||
"""Abslute path to the file
|
"""Abslute path to the file
|
||||||
without leading slash
|
without leading slash
|
||||||
including filename
|
including filename
|
||||||
|
@ -246,7 +238,6 @@ class AternosFile:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
|
|
||||||
"""Filename with extension
|
"""Filename with extension
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -257,7 +248,6 @@ class AternosFile:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dirname(self) -> str:
|
def dirname(self) -> str:
|
||||||
|
|
||||||
"""Full path to the directory
|
"""Full path to the directory
|
||||||
which contains the file
|
which contains the file
|
||||||
without leading slash.
|
without leading slash.
|
||||||
|
@ -271,7 +261,6 @@ class AternosFile:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def deleteable(self) -> bool:
|
def deleteable(self) -> bool:
|
||||||
|
|
||||||
"""True if the file can be deleted,
|
"""True if the file can be deleted,
|
||||||
otherwise False
|
otherwise False
|
||||||
|
|
||||||
|
@ -283,7 +272,6 @@ class AternosFile:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def downloadable(self) -> bool:
|
def downloadable(self) -> bool:
|
||||||
|
|
||||||
"""True if the file can be downloaded,
|
"""True if the file can be downloaded,
|
||||||
otherwise False
|
otherwise False
|
||||||
|
|
||||||
|
@ -295,7 +283,6 @@ class AternosFile:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def editable(self) -> bool:
|
def editable(self) -> bool:
|
||||||
|
|
||||||
"""True if the file can be
|
"""True if the file can be
|
||||||
opened in Aternos editor,
|
opened in Aternos editor,
|
||||||
otherwise False
|
otherwise False
|
||||||
|
@ -308,7 +295,6 @@ class AternosFile:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ftype(self) -> FileType:
|
def ftype(self) -> FileType:
|
||||||
|
|
||||||
"""File object type: file or directory
|
"""File object type: file or directory
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -319,7 +305,6 @@ class AternosFile:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_dir(self) -> bool:
|
def is_dir(self) -> bool:
|
||||||
|
|
||||||
"""Check if the file object is a directory
|
"""Check if the file object is a directory
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -330,7 +315,6 @@ class AternosFile:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_file(self) -> bool:
|
def is_file(self) -> bool:
|
||||||
|
|
||||||
"""Check if the file object is not a directory
|
"""Check if the file object is not a directory
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -341,7 +325,6 @@ class AternosFile:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def size(self) -> float:
|
def size(self) -> float:
|
||||||
|
|
||||||
"""File size in bytes
|
"""File size in bytes
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
|
@ -16,7 +16,6 @@ class FileManager:
|
||||||
for viewing files structure"""
|
for viewing files structure"""
|
||||||
|
|
||||||
def __init__(self, atserv: 'AternosServer') -> None:
|
def __init__(self, atserv: 'AternosServer') -> None:
|
||||||
|
|
||||||
"""Aternos file manager class
|
"""Aternos file manager class
|
||||||
for viewing files structure
|
for viewing files structure
|
||||||
|
|
||||||
|
@ -28,7 +27,6 @@ class FileManager:
|
||||||
self.atserv = atserv
|
self.atserv = atserv
|
||||||
|
|
||||||
def list_dir(self, path: str = '') -> List[AternosFile]:
|
def list_dir(self, path: str = '') -> List[AternosFile]:
|
||||||
|
|
||||||
"""Requests a list of files
|
"""Requests a list of files
|
||||||
in the specified directory
|
in the specified directory
|
||||||
|
|
||||||
|
@ -83,7 +81,6 @@ class FileManager:
|
||||||
return files
|
return files
|
||||||
|
|
||||||
def extract_size(self, fsize_raw: List[Any]) -> float:
|
def extract_size(self, fsize_raw: List[Any]) -> float:
|
||||||
|
|
||||||
"""Parses file size from the LXML tree
|
"""Parses file size from the LXML tree
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -113,7 +110,6 @@ class FileManager:
|
||||||
self,
|
self,
|
||||||
num: Union[int, float],
|
num: Union[int, float],
|
||||||
measure: str) -> float:
|
measure: str) -> float:
|
||||||
|
|
||||||
"""Converts "human" file size to size in bytes
|
"""Converts "human" file size to size in bytes
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -133,7 +129,6 @@ class FileManager:
|
||||||
return measure_match.get(measure, -1) * num
|
return measure_match.get(measure, -1) * num
|
||||||
|
|
||||||
def get_file(self, path: str) -> Optional[AternosFile]:
|
def get_file(self, path: str) -> Optional[AternosFile]:
|
||||||
|
|
||||||
"""Returns :class:`python_aternos.atfile.AternosFile`
|
"""Returns :class:`python_aternos.atfile.AternosFile`
|
||||||
instance by its path
|
instance by its path
|
||||||
|
|
||||||
|
@ -158,7 +153,6 @@ class FileManager:
|
||||||
}.get('file', None)
|
}.get('file', None)
|
||||||
|
|
||||||
def dl_file(self, path: str) -> bytes:
|
def dl_file(self, path: str) -> bytes:
|
||||||
|
|
||||||
"""Returns the file content in bytes (downloads it)
|
"""Returns the file content in bytes (downloads it)
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -178,7 +172,6 @@ class FileManager:
|
||||||
return file.content
|
return file.content
|
||||||
|
|
||||||
def dl_world(self, world: str = 'world') -> bytes:
|
def dl_world(self, world: str = 'world') -> bytes:
|
||||||
|
|
||||||
"""Returns the world zip file content
|
"""Returns the world zip file content
|
||||||
by its name (downloads it)
|
by its name (downloads it)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ arrowexp = regex.compile(r'\w[^\}]*+')
|
||||||
|
|
||||||
|
|
||||||
def to_ecma5_function(f: str) -> str:
|
def to_ecma5_function(f: str) -> str:
|
||||||
|
|
||||||
"""Converts a ECMA6 function
|
"""Converts a ECMA6 function
|
||||||
to ECMA5 format (without arrow expressions)
|
to ECMA5 format (without arrow expressions)
|
||||||
|
|
||||||
|
@ -31,7 +30,6 @@ def to_ecma5_function(f: str) -> str:
|
||||||
|
|
||||||
|
|
||||||
def atob(s: str) -> str:
|
def atob(s: str) -> str:
|
||||||
|
|
||||||
"""Decodes base64 string
|
"""Decodes base64 string
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -45,7 +43,6 @@ def atob(s: str) -> str:
|
||||||
|
|
||||||
|
|
||||||
def exec_js(f: str) -> js2py.EvalJs:
|
def exec_js(f: str) -> js2py.EvalJs:
|
||||||
|
|
||||||
"""Executes a JavaScript function
|
"""Executes a JavaScript function
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|
|
@ -32,7 +32,6 @@ class PlayersList:
|
||||||
self,
|
self,
|
||||||
lst: Union[str, Lists],
|
lst: Union[str, Lists],
|
||||||
atserv: 'AternosServer') -> None:
|
atserv: 'AternosServer') -> None:
|
||||||
|
|
||||||
"""Class for managing operators,
|
"""Class for managing operators,
|
||||||
whitelist and banned players lists
|
whitelist and banned players lists
|
||||||
|
|
||||||
|
@ -60,7 +59,6 @@ class PlayersList:
|
||||||
self.parsed = False
|
self.parsed = False
|
||||||
|
|
||||||
def list_players(self, cache: bool = True) -> List[str]:
|
def list_players(self, cache: bool = True) -> List[str]:
|
||||||
|
|
||||||
"""Parse a players list
|
"""Parse a players list
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -93,7 +91,6 @@ class PlayersList:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def add(self, name: str) -> None:
|
def add(self, name: str) -> None:
|
||||||
|
|
||||||
"""Appends a player to the list by the nickname
|
"""Appends a player to the list by the nickname
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -111,7 +108,6 @@ class PlayersList:
|
||||||
self.players.append(name)
|
self.players.append(name)
|
||||||
|
|
||||||
def remove(self, name: str) -> None:
|
def remove(self, name: str) -> None:
|
||||||
|
|
||||||
"""Removes a player from the list by the nickname
|
"""Removes a player from the list by the nickname
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|
|
@ -53,7 +53,6 @@ class AternosServer:
|
||||||
self, servid: str,
|
self, servid: str,
|
||||||
atconn: AternosConnect,
|
atconn: AternosConnect,
|
||||||
reqinfo: bool = True) -> None:
|
reqinfo: bool = True) -> None:
|
||||||
|
|
||||||
"""Class for controlling your Aternos Minecraft server
|
"""Class for controlling your Aternos Minecraft server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -70,7 +69,6 @@ class AternosServer:
|
||||||
self.fetch()
|
self.fetch()
|
||||||
|
|
||||||
def fetch(self) -> None:
|
def fetch(self) -> None:
|
||||||
|
|
||||||
"""Send a request to Aternos API to get all server info"""
|
"""Send a request to Aternos API to get all server info"""
|
||||||
|
|
||||||
servreq = self.atserver_request(
|
servreq = self.atserver_request(
|
||||||
|
@ -80,7 +78,6 @@ class AternosServer:
|
||||||
self._info = json.loads(servreq.content)
|
self._info = json.loads(servreq.content)
|
||||||
|
|
||||||
def wss(self, autoconfirm: bool = False) -> AternosWss:
|
def wss(self, autoconfirm: bool = False) -> AternosWss:
|
||||||
|
|
||||||
"""Returns AternosWss instance for
|
"""Returns AternosWss instance for
|
||||||
listening server streams in real-time
|
listening server streams in real-time
|
||||||
|
|
||||||
|
@ -100,7 +97,6 @@ class AternosServer:
|
||||||
self,
|
self,
|
||||||
headstart: bool = False,
|
headstart: bool = False,
|
||||||
accepteula: bool = True) -> None:
|
accepteula: bool = True) -> None:
|
||||||
|
|
||||||
"""Starts a server
|
"""Starts a server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -135,7 +131,6 @@ class AternosServer:
|
||||||
raise ServerStartError(error)
|
raise ServerStartError(error)
|
||||||
|
|
||||||
def confirm(self) -> None:
|
def confirm(self) -> None:
|
||||||
|
|
||||||
"""Confirms server launching"""
|
"""Confirms server launching"""
|
||||||
|
|
||||||
self.atserver_request(
|
self.atserver_request(
|
||||||
|
@ -144,7 +139,6 @@ class AternosServer:
|
||||||
)
|
)
|
||||||
|
|
||||||
def stop(self) -> None:
|
def stop(self) -> None:
|
||||||
|
|
||||||
"""Stops the server"""
|
"""Stops the server"""
|
||||||
|
|
||||||
self.atserver_request(
|
self.atserver_request(
|
||||||
|
@ -153,7 +147,6 @@ class AternosServer:
|
||||||
)
|
)
|
||||||
|
|
||||||
def cancel(self) -> None:
|
def cancel(self) -> None:
|
||||||
|
|
||||||
"""Cancels server launching"""
|
"""Cancels server launching"""
|
||||||
|
|
||||||
self.atserver_request(
|
self.atserver_request(
|
||||||
|
@ -162,7 +155,6 @@ class AternosServer:
|
||||||
)
|
)
|
||||||
|
|
||||||
def restart(self) -> None:
|
def restart(self) -> None:
|
||||||
|
|
||||||
"""Restarts the server"""
|
"""Restarts the server"""
|
||||||
|
|
||||||
self.atserver_request(
|
self.atserver_request(
|
||||||
|
@ -171,7 +163,6 @@ class AternosServer:
|
||||||
)
|
)
|
||||||
|
|
||||||
def eula(self) -> None:
|
def eula(self) -> None:
|
||||||
|
|
||||||
"""Accepts the Mojang EULA"""
|
"""Accepts the Mojang EULA"""
|
||||||
|
|
||||||
self.atserver_request(
|
self.atserver_request(
|
||||||
|
@ -180,7 +171,6 @@ class AternosServer:
|
||||||
)
|
)
|
||||||
|
|
||||||
def files(self) -> FileManager:
|
def files(self) -> FileManager:
|
||||||
|
|
||||||
"""Returns FileManager instance
|
"""Returns FileManager instance
|
||||||
for file operations
|
for file operations
|
||||||
|
|
||||||
|
@ -191,7 +181,6 @@ class AternosServer:
|
||||||
return FileManager(self)
|
return FileManager(self)
|
||||||
|
|
||||||
def config(self) -> AternosConfig:
|
def config(self) -> AternosConfig:
|
||||||
|
|
||||||
"""Returns AternosConfig instance
|
"""Returns AternosConfig instance
|
||||||
for editing server settings
|
for editing server settings
|
||||||
|
|
||||||
|
@ -202,7 +191,6 @@ class AternosServer:
|
||||||
return AternosConfig(self)
|
return AternosConfig(self)
|
||||||
|
|
||||||
def players(self, lst: Lists) -> PlayersList:
|
def players(self, lst: Lists) -> PlayersList:
|
||||||
|
|
||||||
"""Returns PlayersList instance
|
"""Returns PlayersList instance
|
||||||
for managing operators, whitelist
|
for managing operators, whitelist
|
||||||
and banned players lists
|
and banned players lists
|
||||||
|
@ -223,7 +211,6 @@ class AternosServer:
|
||||||
data: Optional[Dict[Any, Any]] = None,
|
data: Optional[Dict[Any, Any]] = None,
|
||||||
headers: Optional[Dict[Any, Any]] = None,
|
headers: Optional[Dict[Any, Any]] = None,
|
||||||
sendtoken: bool = False) -> requests.Response:
|
sendtoken: bool = False) -> requests.Response:
|
||||||
|
|
||||||
"""Sends a request to Aternos API
|
"""Sends a request to Aternos API
|
||||||
with server IDenitfier parameter
|
with server IDenitfier parameter
|
||||||
|
|
||||||
|
@ -253,7 +240,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def subdomain(self) -> str:
|
def subdomain(self) -> str:
|
||||||
|
|
||||||
"""Server subdomain
|
"""Server subdomain
|
||||||
(the part of domain before `.aternos.me`)
|
(the part of domain before `.aternos.me`)
|
||||||
|
|
||||||
|
@ -266,7 +252,6 @@ class AternosServer:
|
||||||
|
|
||||||
@subdomain.setter
|
@subdomain.setter
|
||||||
def subdomain(self, value: str) -> None:
|
def subdomain(self, value: str) -> None:
|
||||||
|
|
||||||
"""Set a new subdomain for your server
|
"""Set a new subdomain for your server
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -281,7 +266,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def motd(self) -> str:
|
def motd(self) -> str:
|
||||||
|
|
||||||
"""Server message of the day
|
"""Server message of the day
|
||||||
which is shown below its name
|
which is shown below its name
|
||||||
in the Minecraft servers list
|
in the Minecraft servers list
|
||||||
|
@ -294,7 +278,6 @@ class AternosServer:
|
||||||
|
|
||||||
@motd.setter
|
@motd.setter
|
||||||
def motd(self, value: str) -> None:
|
def motd(self, value: str) -> None:
|
||||||
|
|
||||||
"""Set a new message of the day
|
"""Set a new message of the day
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -309,7 +292,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def address(self) -> str:
|
def address(self) -> str:
|
||||||
|
|
||||||
"""Full server address
|
"""Full server address
|
||||||
including domain and port
|
including domain and port
|
||||||
|
|
||||||
|
@ -321,7 +303,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def domain(self) -> str:
|
def domain(self) -> str:
|
||||||
|
|
||||||
"""Server domain (e.g. `test.aternos.me`).
|
"""Server domain (e.g. `test.aternos.me`).
|
||||||
In other words, address without port number
|
In other words, address without port number
|
||||||
|
|
||||||
|
@ -333,7 +314,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def port(self) -> int:
|
def port(self) -> int:
|
||||||
|
|
||||||
"""Server port number
|
"""Server port number
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -344,7 +324,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def edition(self) -> Edition:
|
def edition(self) -> Edition:
|
||||||
|
|
||||||
"""Server software edition: Java or Bedrock
|
"""Server software edition: Java or Bedrock
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -356,7 +335,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_java(self) -> bool:
|
def is_java(self) -> bool:
|
||||||
|
|
||||||
"""Check if server software is Java Edition
|
"""Check if server software is Java Edition
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -367,7 +345,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_bedrock(self) -> bool:
|
def is_bedrock(self) -> bool:
|
||||||
|
|
||||||
"""Check if server software is Bedrock Edition
|
"""Check if server software is Bedrock Edition
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -378,7 +355,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def software(self) -> str:
|
def software(self) -> str:
|
||||||
|
|
||||||
"""Server software name (e.g. `Vanilla`)
|
"""Server software name (e.g. `Vanilla`)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -389,7 +365,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def version(self) -> str:
|
def version(self) -> str:
|
||||||
|
|
||||||
"""Server software version (1.16.5)
|
"""Server software version (1.16.5)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -400,7 +375,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def css_class(self) -> str:
|
def css_class(self) -> str:
|
||||||
|
|
||||||
"""CSS class for
|
"""CSS class for
|
||||||
server status block
|
server status block
|
||||||
on official web site
|
on official web site
|
||||||
|
@ -415,7 +389,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def status(self) -> str:
|
def status(self) -> str:
|
||||||
|
|
||||||
"""Server status string
|
"""Server status string
|
||||||
(offline, loading, preparing)
|
(offline, loading, preparing)
|
||||||
|
|
||||||
|
@ -427,7 +400,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def status_num(self) -> Status:
|
def status_num(self) -> Status:
|
||||||
|
|
||||||
"""Server numeric status.
|
"""Server numeric status.
|
||||||
It is highly recommended to use
|
It is highly recommended to use
|
||||||
status string instead of a number
|
status string instead of a number
|
||||||
|
@ -440,7 +412,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def players_list(self) -> List[str]:
|
def players_list(self) -> List[str]:
|
||||||
|
|
||||||
"""List of connected players' nicknames
|
"""List of connected players' nicknames
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -451,7 +422,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def players_count(self) -> int:
|
def players_count(self) -> int:
|
||||||
|
|
||||||
"""How many players are connected
|
"""How many players are connected
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -462,7 +432,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def slots(self) -> int:
|
def slots(self) -> int:
|
||||||
|
|
||||||
"""Server slots, how many
|
"""Server slots, how many
|
||||||
players **can** connect
|
players **can** connect
|
||||||
|
|
||||||
|
@ -474,7 +443,6 @@ class AternosServer:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ram(self) -> int:
|
def ram(self) -> int:
|
||||||
|
|
||||||
"""Server used RAM in MB
|
"""Server used RAM in MB
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
|
@ -49,7 +49,6 @@ class AternosWss:
|
||||||
self,
|
self,
|
||||||
atserv: 'AternosServer',
|
atserv: 'AternosServer',
|
||||||
autoconfirm: bool = False) -> None:
|
autoconfirm: bool = False) -> None:
|
||||||
|
|
||||||
"""Class for managing websocket connection
|
"""Class for managing websocket connection
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -95,7 +94,6 @@ class AternosWss:
|
||||||
self,
|
self,
|
||||||
stream: Streams,
|
stream: Streams,
|
||||||
arg: Tuple[Any, ...] = ()) -> Callable[[FunctionT], Any]:
|
arg: Tuple[Any, ...] = ()) -> Callable[[FunctionT], Any]:
|
||||||
|
|
||||||
"""Decorator that marks your function as a stream receiver.
|
"""Decorator that marks your function as a stream receiver.
|
||||||
When websocket receives message from the specified stream,
|
When websocket receives message from the specified stream,
|
||||||
it calls all listeners created with this decorator.
|
it calls all listeners created with this decorator.
|
||||||
|
|
Reference in a new issue