def form_valid(self, form): form.save(instance=self.object) check = self.object.get_check_instance() datawatch.get_backend().run(slug=check.slug, identifier=check.get_identifier( self.object), run_async=False) return super(ResultConfigView, self).form_valid(form)
def get(self, request, *args, **kwargs): self.object = self.get_object() response = super(ResultRefreshView, self).get(request, *args, **kwargs) check = self.object.get_check_instance() datawatch.get_backend().run(slug=check.slug, identifier=self.object.identifier, async=False) messages.add_message(request, messages.INFO, _('Result has been refreshed')) return response
def enqueue(self, slug, run_async=True): check = self._get_check_instance(slug) if not check: return try: for payload in check.generate(): datawatch.get_backend().run( check.slug, check.get_identifier(payload)) except NotImplementedError as e: logger.error(e)
def refresh(self, slug): backend = datawatch.get_backend() backend.refresh(slug=slug, async=True)
def refresh(self, slug, run_async=True): for result in Result.objects.filter(slug=slug): datawatch.get_backend().run(result.slug, result.identifier)
def refresh(self): datawatch.get_backend().refresh(slug=self.slug)
def run(self): datawatch.get_backend().enqueue(slug=self.slug) CheckExecution.objects.update_or_create( slug=self.slug, defaults=dict(last_run=timezone.now()))
class Backend(BaseBackend): def enqueue(self, slug, async=True): check = self._get_check_instance(slug) if not check: return try: for payload in check.generate(): datawatch.get_backend().run(check.slug, check.get_identifier(payload)) except NotImplementedError as e: logger.error(e) def refresh(self, slug, async=True): for result in Result.objects.filter(slug=slug): datawatch.get_backend().run(result.slug, result.identifier) def run(self, slug, identifier, async=True): check = self._get_check_instance(slug) if not check: return try: payload = check.get_payload(identifier) except NotImplementedError as e: logger.error(e) return except ObjectDoesNotExist: Result.objects.filter(slug=slug, identifier=identifier).delete() return