update webhook start and end payloads

pull/476/head
meisnate12 3 years ago
parent 0ea91d60e7
commit 03e77ab2ac

@ -3,8 +3,6 @@ name: Docker Latest Release
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:

@ -44,7 +44,7 @@ class Config:
self.default_dir = default_dir
self.test_mode = attrs["test"] if "test" in attrs else False
self.trace_mode = attrs["trace"] if "trace" in attrs else False
self.run_start_time = attrs["time"]
self.start_time = attrs["time_obj"]
self.run_hour = datetime.strptime(attrs["time"], "%H:%M").hour
self.requested_collections = util.get_list(attrs["collections"]) if "collections" in attrs else None
self.requested_libraries = util.get_list(attrs["libraries"]) if "libraries" in attrs else None
@ -231,7 +231,7 @@ class Config:
self.Webhooks = Webhooks(self, self.webhooks, notifiarr=self.NotifiarrFactory)
try:
self.Webhooks.start_time_hooks(self.run_start_time)
self.Webhooks.start_time_hooks(self.start_time)
except Failed as e:
util.print_stacktrace()
logger.error(f"Webhooks Error: {e}")

@ -43,12 +43,13 @@ class Webhooks:
def start_time_hooks(self, start_time):
if self.run_start_webhooks:
self._request(self.run_start_webhooks, {"start_time": start_time})
self._request(self.run_start_webhooks, {"start_time": start_time.strftime("%Y-%m-%d %H:%M:%S")})
def end_time_hooks(self, start_time, run_time, stats):
def end_time_hooks(self, start_time, end_time, run_time, stats):
if self.run_end_webhooks:
self._request(self.run_end_webhooks, {
"start_time": start_time.strftime("%Y-%m-%dT%H:%M:%SZ"),
"start_time": start_time.strftime("%Y-%m-%d %H:%M:%S"),
"end_time": end_time.strftime("%Y-%m-%d %H:%M:%S"),
"run_time": run_time,
"collections_created": stats["created"],
"collections_modified": stats["modified"],

@ -135,6 +135,7 @@ def start(attrs):
start_time = datetime.now()
if "time" not in attrs:
attrs["time"] = start_time.strftime("%H:%M")
attrs["time_obj"] = start_time
util.separator(f"Starting {start_type}Run")
config = None
global stats
@ -152,10 +153,11 @@ def start(attrs):
util.print_stacktrace()
util.print_multiline(e, critical=True)
logger.info("")
run_time = str(datetime.now() - start_time).split('.')[0]
end_time = datetime.now()
run_time = str(end_time - start_time).split('.')[0]
if config:
try:
config.Webhooks.end_time_hooks(start_time, run_time, stats)
config.Webhooks.end_time_hooks(start_time, end_time, run_time, stats)
except Failed as e:
util.print_stacktrace()
logger.error(f"Webhooks Error: {e}")

Loading…
Cancel
Save