From ad351e594a3aa0f9cd2024d93f0ddb1f33ed9a8e Mon Sep 17 00:00:00 2001 From: def Date: Mon, 5 Sep 2022 10:31:12 +0200 Subject: [PATCH] add base for project --- config.yaml | 7 +++++ main.py | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ project.log | 6 +++++ requirements.txt | 3 +++ 4 files changed, 82 insertions(+) create mode 100644 config.yaml create mode 100644 main.py create mode 100644 project.log create mode 100644 requirements.txt diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..717f4ff --- /dev/null +++ b/config.yaml @@ -0,0 +1,7 @@ +settings: + + rps: + rps_max: 30 + rps_min: 1 + + path_to_proxy: proxy_list.txt diff --git a/main.py b/main.py new file mode 100644 index 0000000..db3df6a --- /dev/null +++ b/main.py @@ -0,0 +1,66 @@ +import pathlib +import sys +from sys import platform + +if platform != "linux": + logger.critical("""\nNot for windows, run only on GNU/Linux!\n""") + input() + sys.exit(1) + +from loguru import logger +import pretty_errors +from colorama import Fore, Back, Style, init +import argparse +import yaml +from psycopg2 import OperationalError + +# try: +# подключение модулей +# except ModuleNotFoundError: +# logger.critical('''\n[Error 2] Module not found! Сheck the integrity of the program!\n''') +# sys.exit(1) + +# try: +# подключение модулей базы данных +# except OperationalError: +# logger.critical('''Type: "sudo systemctl start postgresql"''') +# sys.exit(1) + +parser = argparse.ArgumentParser() + +parser = argparse.ArgumentParser(description="List fish in aquarium.") +parser.add_argument( + "--config", + "-c", + help="Path to the config file", + type=pathlib.Path, + default="config.yaml", +) +parser.add_argument("--proxy", "-p", help="Path to the proxy file", type=pathlib.Path) +parser.add_argument("--rtc_min", help="") +parser.add_argument("--rtc_max", help="") + +args = parser.parse_args() + + +logger.add("project.log") +logger.info("Starting...") + + +with open(args.config) as f: + config = yaml.safe_load(f) + + if args.proxy is None: + path_to_proxy = config.path_to_proxy + else: + path_to_proxy = args.proxy + + if args.rtc_min is None: + rtc_min = config.rtc_min + else: + rtc_min = args.rtc_min + + if args.rtc_max is None: + rtc_max = config.rtc_max + else: + rtc_max = args.rtc_max diff --git a/project.log b/project.log new file mode 100644 index 0000000..3c66ad1 --- /dev/null +++ b/project.log @@ -0,0 +1,6 @@ +2022-09-05 10:05:37.833 | INFO | __main__::35 - Starting... +2022-09-05 10:09:48.622 | INFO | __main__::36 - Starting... +2022-09-05 10:10:43.859 | INFO | __main__::37 - Starting... +2022-09-05 10:11:01.170 | INFO | __main__::37 - Starting... +2022-09-05 10:25:10.856 | INFO | __main__::35 - Starting... +2022-09-05 10:25:38.499 | INFO | __main__::36 - Starting... diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..d217e53 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +loguru +pretty_errors +colorama \ No newline at end of file