How to use the pyppeteer.errors.PyppeteerError function in pyppeteer

To help you get started, we’ve selected a few pyppeteer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github miyakogi / pyppeteer / tests / test_input.py View on Github external
async def test_key_unknown(self):
        with self.assertRaises(PyppeteerError):
            await self.page.keyboard.press('NotARealKey')
        with self.assertRaises(PyppeteerError):
            await self.page.keyboard.press('Ñ‘')
        with self.assertRaises(PyppeteerError):
            await self.page.keyboard.press('😊')
github miyakogi / pyppeteer / tests / test_input.py View on Github external
async def test_key_unknown(self):
        with self.assertRaises(PyppeteerError):
            await self.page.keyboard.press('NotARealKey')
        with self.assertRaises(PyppeteerError):
            await self.page.keyboard.press('Ñ‘')
        with self.assertRaises(PyppeteerError):
            await self.page.keyboard.press('😊')
github web-platform-tests / wpt / tools / pyppeteer / pyppeteer / connection.py View on Github external
if response.getcode() != 200:
            raise PyppeteerError(
                'Unable to close target "{}"'.format(target_id)
            )

        start = time.time()

        while time.time() - start < _CLOSE_TARGET_TIMEOUT:
            ids = [target['targetId'] for target in self.targets()]

            if target_id not in ids:
                return

            time.sleep(_CLOSE_TARGET_POLL_INTERVAL)

        raise PyppeteerError(
            'Unable to close target "{}" after {} seconds'.format(
                target_id, _CLOSE_TARGET_TIMEOUT
            )
github miyakogi / pyppeteer / pyppeteer / errors.py View on Github external
"""Exceptions for pyppeteer package."""

import asyncio


class PyppeteerError(Exception):  # noqa: D204
    """Base exception for pyppeteer."""
    pass


class BrowserError(PyppeteerError):  # noqa: D204
    """Exception raised from browser."""
    pass


class ElementHandleError(PyppeteerError):  # noqa: D204
    """ElementHandle related exception."""
    pass


class NetworkError(PyppeteerError):  # noqa: D204
    """Network/Protocol related exception."""
    pass


class PageError(PyppeteerError):  # noqa: D204
    """Page/Frame related exception."""
    pass


class TimeoutError(asyncio.TimeoutError):  # noqa: D204
    """Timeout Error class."""
github miyakogi / pyppeteer / pyppeteer / input.py View on Github external
def _keyDescriptionForString(self, keyString: str) -> Dict:  # noqa: C901
        shift = self._modifiers & 8
        description = {
            'key': '',
            'keyCode': 0,
            'code': '',
            'text': '',
            'location': 0,
        }

        definition: Dict = keyDefinitions.get(keyString)  # type: ignore
        if not definition:
            raise PyppeteerError(f'Unknown key: {keyString}')

        if 'key' in definition:
            description['key'] = definition['key']
        if shift and definition.get('shiftKey'):
            description['key'] = definition['shiftKey']

        if 'keyCode' in definition:
            description['keyCode'] = definition['keyCode']
        if shift and definition.get('shiftKeyCode'):
            description['keyCode'] = definition['shiftKeyCode']

        if 'code' in definition:
            description['code'] = definition['code']

        if 'location' in definition:
            description['location'] = definition['location']
github miyakogi / pyppeteer / pyppeteer / errors.py View on Github external
class BrowserError(PyppeteerError):  # noqa: D204
    """Exception raised from browser."""
    pass


class ElementHandleError(PyppeteerError):  # noqa: D204
    """ElementHandle related exception."""
    pass


class NetworkError(PyppeteerError):  # noqa: D204
    """Network/Protocol related exception."""
    pass


class PageError(PyppeteerError):  # noqa: D204
    """Page/Frame related exception."""
    pass


class TimeoutError(asyncio.TimeoutError):  # noqa: D204
    """Timeout Error class."""
    pass
github miyakogi / pyppeteer / pyppeteer / errors.py View on Github external
class PyppeteerError(Exception):  # noqa: D204
    """Base exception for pyppeteer."""
    pass


class BrowserError(PyppeteerError):  # noqa: D204
    """Exception raised from browser."""
    pass


class ElementHandleError(PyppeteerError):  # noqa: D204
    """ElementHandle related exception."""
    pass


class NetworkError(PyppeteerError):  # noqa: D204
    """Network/Protocol related exception."""
    pass


class PageError(PyppeteerError):  # noqa: D204
    """Page/Frame related exception."""
    pass


class TimeoutError(asyncio.TimeoutError):  # noqa: D204
    """Timeout Error class."""
    pass
github JohnDoee / rippy / rippy / tasks.py View on Github external
try:
            chrome_url = get_chrome_url()
        except:
            logger.exception("Failed to get chrome URL")

            job.status_message = "Failed to get chrome URL"
            job.status = job.FAILED
            job.save()

            return

        try:
            result = asyncio.get_event_loop().run_until_complete(
                execute_job(extractor_cls, chrome_url, job)
            )
        except (errors.PyppeteerError, asyncio.TimeoutError):
            logger.exception("Pyppeteer failed, attempt %s of 3" % (i + 1))
            time.sleep(5)
        else:
            break
    else:
        job.status_message = "Failed to get puppeteer to get url"
        job.status = job.FAILED
        job.save()

        return

    media_path = str(job.pk)
    target_path = os.path.join(settings.MEDIA_ROOT, media_path)
    if not os.path.isdir(target_path):
        os.makedirs(target_path)
github miyakogi / pyppeteer / pyppeteer / errors.py View on Github external
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""Exceptions for pyppeteer package."""

import asyncio


class PyppeteerError(Exception):  # noqa: D204
    """Base exception for pyppeteer."""
    pass


class BrowserError(PyppeteerError):  # noqa: D204
    """Exception raised from browser."""
    pass


class ElementHandleError(PyppeteerError):  # noqa: D204
    """ElementHandle related exception."""
    pass


class NetworkError(PyppeteerError):  # noqa: D204
    """Network/Protocol related exception."""
    pass


class PageError(PyppeteerError):  # noqa: D204
    """Page/Frame related exception."""
github imWildCat / scylla / scylla / scheduler.py View on Github external
if html:
                    proxies = provider.parse(html)

                    for p in proxies:
                        validator_queue.put(p)
                        # logger.debug('Put new proxy ip into queue: {}'.format(p.__str__()))

                    logger.info(
                        ' {}: feed {} potential proxies into the validator queue'.format(provider_name, len(proxies))
                    )
        except (KeyboardInterrupt, InterruptedError, SystemExit):
            worker.stop()
            logger.info('worker_process exited.')
            break
        except pyppeteer.errors.PyppeteerError as e:
            logger.debug("""pyppeteer.errors.PyppeteerError detected: %s\n
                         'Please make sure you have installed all the dependencies for chromium correctly""", e)