Added confiigurable number of try if error

main
Jan Beníček 2024-06-26 06:06:53 +02:00
parent 558d7cbc64
commit 3fa9b563be
3 changed files with 5 additions and 3 deletions

View File

@ -6,4 +6,5 @@ DISCORD_WEBHOOK=https://webhookaddress
MAIN_DOMAIN=http://baseOfDomainForbackupsPropagationViaWebhook
DISCORD_BACKUPNAME=ServerName
DISCORD_ENABLED=1
BACKUPS_KEEP_DAYS=4
BACKUPS_KEEP_DAYS=4
TRY_NUMBER=5

View File

@ -12,6 +12,7 @@ class Config(BaseSettings):
discord_enabled: int
discord_backupname: str
backups_keep_days: int
try_number: int
cfg = Config()

View File

@ -2,8 +2,8 @@ from conf import get_config
import pterodactylReader, fileDownloader, datetime, discordPoster, time, oldRemover
def run(run_number: int):
conf = get_config()
try:
conf = get_config()
api_client = pterodactylReader.init_client(config=conf)
today_date = datetime.datetime.now()
@ -26,7 +26,7 @@ def run(run_number: int):
except Exception as e:
print(f"Error on try #{run_number}: {e}")
if run_number < 5:
if run_number < conf.try_number:
run(run_number=(run_number + 1))