Update config with arguments
This commit is contained in:
parent
7840593370
commit
e545e458af
|
@ -1,7 +1,6 @@
|
||||||
settings:
|
settings:
|
||||||
|
|
||||||
rps:
|
|
||||||
rps_max: 30
|
rps_max: 30
|
||||||
rps_min: 1
|
rps_min: 1
|
||||||
|
|
||||||
path_to_proxy: proxy_list.txt
|
proxy: proxy_list.txt
|
||||||
|
|
65
main.py
65
main.py
|
@ -1,66 +1,45 @@
|
||||||
|
from loguru import logger
|
||||||
|
import pretty_errors
|
||||||
|
from colorama import Fore, Back, Style, init
|
||||||
|
|
||||||
|
import pathlib
|
||||||
|
import argparse
|
||||||
|
import yaml
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from sys import platform
|
from sys import platform
|
||||||
|
|
||||||
|
|
||||||
if platform != "linux":
|
if platform != "linux":
|
||||||
logger.critical("""\nNot for windows, run only on GNU/Linux!\n""")
|
logger.critical("""\nNot for windows, run only on GNU/Linux!\n""")
|
||||||
input()
|
input()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
import pathlib
|
parser = argparse.ArgumentParser(
|
||||||
from loguru import logger
|
description="List fish in aquarium.",
|
||||||
import pretty_errors
|
argument_default=argparse.SUPPRESS
|
||||||
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(
|
parser.add_argument(
|
||||||
"--config",
|
"--config", "-c",
|
||||||
"-c",
|
|
||||||
help="Path to the config file",
|
help="Path to the config file",
|
||||||
type=pathlib.Path,
|
type=pathlib.Path,
|
||||||
default="config.yaml",
|
default="config.yaml",
|
||||||
)
|
)
|
||||||
parser.add_argument("--proxy", "-p", help="Path to the proxy file", type=pathlib.Path)
|
parser.add_argument(
|
||||||
|
"--proxy", "-p",
|
||||||
|
help="Path to the proxy file",
|
||||||
|
type=pathlib.Path
|
||||||
|
)
|
||||||
parser.add_argument("--rtc_min", help="", type=int)
|
parser.add_argument("--rtc_min", help="", type=int)
|
||||||
parser.add_argument("--rtc_max", help="", type=int)
|
parser.add_argument("--rtc_max", help="", type=int)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = vars(parser.parse_args())
|
||||||
|
|
||||||
|
|
||||||
logger.add("project.log")
|
logger.add("project.log")
|
||||||
logger.info("Starting...")
|
logger.info("Starting...")
|
||||||
|
|
||||||
|
|
||||||
with open(args.config) as f:
|
with open(args["config"]) as f:
|
||||||
config = yaml.safe_load(f)
|
config = yaml.safe_load(f)
|
||||||
|
config["settings"].update(args)
|
||||||
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
|
|
||||||
|
|
Reference in a new issue