Exemplo n.º 1
0
    def testWebScreenshotExtractor(self):
        screenshot = get_web_screenshot('http://google.com')

        s = urllib2.urlopen(screenshot)
        self.assertEqual(s.headers.type, 'image/jpeg')

        # Bad url should raise an exception
        with self.assertRaises(BaseWebkitException):
            get_web_screenshot('weeeeeeeeeeeeeeeeeeeeeee')
Exemplo n.º 2
0
    def testWebScreenshotExtractor(self):
        screenshot = get_web_screenshot('http://google.com')

        s = urllib2.urlopen(screenshot)
        self.assertEqual(s.headers.type, 'image/jpeg')

        # Bad url should raise an exception
        with self.assertRaises(BaseWebkitException):
            get_web_screenshot('weeeeeeeeeeeeeeeeeeeeeee')
Exemplo n.º 3
0
def web_screenshot_extraction(sample_id, url=None, *args, **kwargs):
    """ Generates html output from those browsers.
    """
    if url is None:
        url = Sample.objects.get(id=sample_id).url

    if not is_proper_url(url):
        return False

    sample = Sample.objects.get(id=sample_id)
    try:
        screenshot = get_web_screenshot(url)
        Sample.objects.filter(id=sample_id).update(screenshot=screenshot)

        send_event(
            "EventSampleScreenshotDone",
            sample_id=sample_id,
            sample_url=sample.url,
            job_id=sample.job_id,
        )
    except BaseWebkitException, e:
        send_event(
            "EventSampleScreenshotFail",
            sample_id=sample_id,
            sample_url=sample.url,
            job_id=sample.job_id,
            error_code=e.status_code,
        )
        return False