From ff8eaad69aa20973519ba95df026123fef59bff2 Mon Sep 17 00:00:00 2001 From: ge Date: Fri, 8 Apr 2022 21:08:05 +0300 Subject: [PATCH 1/3] Add setup.py --- setup.py | 32 ++++++++++++++++++++++++++++++++ twvdscli.py | 1 + 2 files changed, 33 insertions(+) create mode 100644 setup.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..27bac68 --- /dev/null +++ b/setup.py @@ -0,0 +1,32 @@ +from setuptools import setup + + +with open("README.md", "r") as long_descr: + long_description = long_descr.read() + +setup( + name = 'twvdscli', + version = '1.0', + author = 'L0sted', + description = 'Servers and services manage tool for Timeweb Cloud', + long_description = long_description, + long_description_content_type = "text/markdown", + url = 'https://github.com/L0sted/twvdscli', + classifiers = [ + "Programming Language :: Python :: 3.10", + "License :: OSI Approved :: The Unlicense (Unlicense)", + "Operating System :: OS Independent", + ], + python_requires = '>=3.6', + py_modules = ['twvdscli'], + install_requires = [ + 'typer==0.4.0', + 'prettytable==3.2.0', + 'wcwidth==0.2.5' + ], + entry_points = { + 'console_scripts': [ + 'twvdscli = twvdscli' + ] + } +) diff --git a/twvdscli.py b/twvdscli.py index ed5475a..e088be5 100755 --- a/twvdscli.py +++ b/twvdscli.py @@ -291,6 +291,7 @@ def auth(based): json=dict(refresh_token="string"), headers=headers ) + if not result.ok: return None else: From f4ba7e980384eddd0a04eea3ffca694384a599c9 Mon Sep 17 00:00:00 2001 From: ge Date: Fri, 8 Apr 2022 21:27:45 +0300 Subject: [PATCH 2/3] Add main() function --- setup.py | 3 ++- twvdscli.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 27bac68..87f3f9a 100644 --- a/setup.py +++ b/setup.py @@ -20,13 +20,14 @@ setup( python_requires = '>=3.6', py_modules = ['twvdscli'], install_requires = [ + 'click==7.1.1' 'typer==0.4.0', 'prettytable==3.2.0', 'wcwidth==0.2.5' ], entry_points = { 'console_scripts': [ - 'twvdscli = twvdscli' + 'twvdscli = twvdscli:main' ] } ) diff --git a/twvdscli.py b/twvdscli.py index e088be5..95e999b 100755 --- a/twvdscli.py +++ b/twvdscli.py @@ -323,11 +323,13 @@ def get_api_key(): result = auth(based) return result - -if __name__ == '__main__': +def main(): apikey = get_api_key() if apikey is None: print(typer.style("Auth Error", fg=typer.colors.RED)) sys.exit(1) reqHeader = {"Authorization": "Bearer " + apikey} app() + +if __name__ == '__main__': + main() From 5f54e3817e5d2600b9334cade71fa396ab470cef Mon Sep 17 00:00:00 2001 From: ge Date: Fri, 8 Apr 2022 21:31:59 +0300 Subject: [PATCH 3/3] Update README --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index effb849..6549a0e 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,18 @@ twvdscli # Установка +## С помощью setup.py + +Установка: + +```sh +python setup.py install +``` + +Затем управлять пакетом можно как обычно через pip. + +## Ручная установка + Потребуются пакеты typer, prettytable, requests. Ставим их из файла: ```commandline @@ -13,4 +25,4 @@ pip3 install --user -r requirements.txt # Запуск -При первом запуске утилита спросит логин и пароль, после чего запишет их в ~/.config/twvdscli.ini в формате base64 через знак ":". \ No newline at end of file +При первом запуске утилита спросит логин и пароль, после чего запишет их в ~/.config/twvdscli.ini в формате base64 через знак ":".