This repository has been archived on 2024-07-30. You can view files and clone it, but cannot push or open issues or pull requests.
python-aternos/examples/files_example.py
DarkCat09 4892430f19 MkDocs, Readme, Files API, Automated session saving, v2.0.1
MkDocs: sphinx docstrings rewritten to google, improved config, written the major part of how-to.
Readme: centered title + logo, added badges, features list, updated changelog.

Improved Files API, added automatical session saving and restoring to Client.
Some changes in makefile and gitignore.
License Notice now refers to all contributors.
2022-08-26 16:14:07 +04:00

39 lines
926 B
Python

from getpass import getpass
from python_aternos import Client
user = input('Username: ')
pswd = getpass('Password: ')
aternos = Client.from_credentials(user, pswd)
s = aternos.list_servers()[0]
files = s.files()
while True:
inp = input('> ').strip()
cmd = inp.lower()
if cmd == 'help':
print(
'''Commands list:
help - show this message
quit - exit from the script
world - download the world
list [path] - show directory (or root) contents'''
)
if cmd == 'quit':
break
if cmd.startswith('list'):
path = inp[4:].strip()
directory = files.list_dir(path)
print(path, 'contains:')
for file in directory:
print('\t' + file.name)
if cmd == 'world':
file = files.get_file('/world')
with open('world.zip', 'wb') as f:
f.write(file.get_content())