Added confiigurable number of try if error
parent
558d7cbc64
commit
3fa9b563be
|
@ -6,4 +6,5 @@ DISCORD_WEBHOOK=https://webhookaddress
|
||||||
MAIN_DOMAIN=http://baseOfDomainForbackupsPropagationViaWebhook
|
MAIN_DOMAIN=http://baseOfDomainForbackupsPropagationViaWebhook
|
||||||
DISCORD_BACKUPNAME=ServerName
|
DISCORD_BACKUPNAME=ServerName
|
||||||
DISCORD_ENABLED=1
|
DISCORD_ENABLED=1
|
||||||
BACKUPS_KEEP_DAYS=4
|
BACKUPS_KEEP_DAYS=4
|
||||||
|
TRY_NUMBER=5
|
|
@ -12,6 +12,7 @@ class Config(BaseSettings):
|
||||||
discord_enabled: int
|
discord_enabled: int
|
||||||
discord_backupname: str
|
discord_backupname: str
|
||||||
backups_keep_days: int
|
backups_keep_days: int
|
||||||
|
try_number: int
|
||||||
|
|
||||||
cfg = Config()
|
cfg = Config()
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ from conf import get_config
|
||||||
import pterodactylReader, fileDownloader, datetime, discordPoster, time, oldRemover
|
import pterodactylReader, fileDownloader, datetime, discordPoster, time, oldRemover
|
||||||
|
|
||||||
def run(run_number: int):
|
def run(run_number: int):
|
||||||
|
conf = get_config()
|
||||||
try:
|
try:
|
||||||
conf = get_config()
|
|
||||||
api_client = pterodactylReader.init_client(config=conf)
|
api_client = pterodactylReader.init_client(config=conf)
|
||||||
today_date = datetime.datetime.now()
|
today_date = datetime.datetime.now()
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ def run(run_number: int):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error on try #{run_number}: {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))
|
run(run_number=(run_number + 1))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue