mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2025-10-20 18:56:25 +08:00
Bug Fix: Continue to run on qbit connection error
This commit is contained in:
parent
926c8803e0
commit
49b006f7ce
1 changed files with 25 additions and 10 deletions
|
@ -198,6 +198,10 @@ def start():
|
||||||
start_type = ""
|
start_type = ""
|
||||||
util.separator(f"Starting {start_type}Run")
|
util.separator(f"Starting {start_type}Run")
|
||||||
cfg = None
|
cfg = None
|
||||||
|
body = ''
|
||||||
|
run_time = ''
|
||||||
|
end_time = None
|
||||||
|
next_run = None
|
||||||
global stats
|
global stats
|
||||||
stats = {
|
stats = {
|
||||||
"added": 0,
|
"added": 0,
|
||||||
|
@ -214,11 +218,27 @@ def start():
|
||||||
"pot_unreg": 0,
|
"pot_unreg": 0,
|
||||||
"taggednoHL": 0
|
"taggednoHL": 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def FinishedRun():
|
||||||
|
nonlocal end_time, start_time, start_type, stats_summary, run_time, next_run, body
|
||||||
|
end_time = datetime.now()
|
||||||
|
run_time = str(end_time - start_time).split('.')[0]
|
||||||
|
_, nr = calc_next_run(sch, True)
|
||||||
|
next_run_str = nr['next_run_str']
|
||||||
|
next_run = nr['next_run']
|
||||||
|
body = util.separator(f"Finished {start_type}Run\n{os.linesep.join(stats_summary) if len(stats_summary)>0 else ''}\nRun Time: {run_time}\n{next_run_str if len(next_run_str)>0 else ''}"
|
||||||
|
.replace('\n\n', '\n').rstrip())[0]
|
||||||
|
return next_run, body
|
||||||
try:
|
try:
|
||||||
cfg = Config(default_dir, args)
|
cfg = Config(default_dir, args)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
util.print_stacktrace()
|
if 'Qbittorrent Error' in e.args[0]:
|
||||||
util.print_multiline(e, 'CRITICAL')
|
util.print_multiline(e, 'CRITICAL')
|
||||||
|
FinishedRun()
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
util.print_stacktrace()
|
||||||
|
util.print_multiline(e, 'CRITICAL')
|
||||||
|
|
||||||
if cfg:
|
if cfg:
|
||||||
# Set Category
|
# Set Category
|
||||||
|
@ -258,7 +278,7 @@ def start():
|
||||||
num_orphaned = cfg.qbt.rem_orphaned()
|
num_orphaned = cfg.qbt.rem_orphaned()
|
||||||
stats["orphaned"] += num_orphaned
|
stats["orphaned"] += num_orphaned
|
||||||
|
|
||||||
# mpty RecycleBin
|
# Empty RecycleBin
|
||||||
recycle_emptied = cfg.empty_recycle()
|
recycle_emptied = cfg.empty_recycle()
|
||||||
stats["recycle_emptied"] += recycle_emptied
|
stats["recycle_emptied"] += recycle_emptied
|
||||||
|
|
||||||
|
@ -276,13 +296,8 @@ def start():
|
||||||
if stats["untagged"] > 0: stats_summary.append(f"Total noHL Torrents untagged: {stats['untagged']}")
|
if stats["untagged"] > 0: stats_summary.append(f"Total noHL Torrents untagged: {stats['untagged']}")
|
||||||
if stats["recycle_emptied"] > 0: stats_summary.append(f"Total Files Deleted from Recycle Bin: {stats['recycle_emptied']}")
|
if stats["recycle_emptied"] > 0: stats_summary.append(f"Total Files Deleted from Recycle Bin: {stats['recycle_emptied']}")
|
||||||
|
|
||||||
end_time = datetime.now()
|
FinishedRun()
|
||||||
run_time = str(end_time - start_time).split('.')[0]
|
|
||||||
_, nr = calc_next_run(sch, True)
|
|
||||||
next_run_str = nr['next_run_str']
|
|
||||||
next_run = nr['next_run']
|
|
||||||
body = util.separator(f"Finished {start_type}Run\n{os.linesep.join(stats_summary) if len(stats_summary)>0 else ''}\nRun Time: {run_time}\n{next_run_str if len(next_run_str)>0 else ''}"
|
|
||||||
.replace('\n\n', '\n').rstrip())[0]
|
|
||||||
if cfg:
|
if cfg:
|
||||||
try:
|
try:
|
||||||
cfg.Webhooks.end_time_hooks(start_time, end_time, run_time, next_run, stats, body)
|
cfg.Webhooks.end_time_hooks(start_time, end_time, run_time, next_run, stats, body)
|
||||||
|
|
Loading…
Add table
Reference in a new issue