Beispiel #1
0
    def create_by_worker(self, *args, **kwargs):
        kwargs['url'] = sanitize_url(kwargs['url'])
        kwargs['source_type'] = SAMPLE_TAGASAURIS_WORKER
        kwargs['source_val'] = kwargs['worker_id']
        del kwargs['worker_id']
        try:
            kwargs['sample'] = Sample.objects.get(
                job=kwargs['job'],
                url=kwargs['url']
            )
        except Sample.DoesNotExist:
            pass

        btm_sample = self.create(**kwargs)
        # If sample exists, step immediately to classification
        if 'sample' in kwargs:
            send_event('EventNewBTMSample',
                sample_id=kwargs['sample'].id,
                job_id=kwargs['job'].id)
        else:
            Sample.objects.create_by_btm(
                job_id=kwargs['job'].id,
                url=kwargs['url'],
                source_val=kwargs['source_val'],
                create_classified=False,
            )

        return btm_sample
Beispiel #2
0
 def _sanitize(self, args, kwargs):
     """
         Sanitizes information passed by users.
     """
     kwargs['url'] = sanitize_url(kwargs['url'])
Beispiel #3
0
 def _sanitize(self, args, kwargs):
     """
         Sanitizes information passed by users.
     """
     kwargs["url"] = sanitize_url(kwargs["url"])