in gnm_deliverables/management/commands/check_vs_notification.py [0:0]
def handle(self, *args, **options):
# seed with current time
random.seed(a=None, version=2)
# wait between 0 and 1 seconds, to try to minimise multiple adds
sleeptime = random.randint(1,8)
print("Waiting {0}s".format(sleeptime))
sleep(sleeptime)
print("Checking for notification {0}...".format(self.our_notification_url))
print("Connecting to Vidispine at {0} as {1}...".format(settings.VIDISPINE_URL, settings.VIDISPINE_USER))
job_notifs = VSNotificationCollection(url=settings.VIDISPINE_URL,user=settings.VIDISPINE_USER, passwd=settings.VIDISPINE_PASSWORD)
already_existing = None
for notification in job_notifs.notifications(objectclass="job"):
if self.is_our_notification(notification):
already_existing = notification
break
if already_existing:
print("Found notification at {0}".format(already_existing.name))
else:
print("No existing notification found.")
self.create_new_notification()