def __init__(self, options, # noqa: C901 **kwargs) -> None: """Make new launcher.""" self.options = merge_dict(options, kwargs) self.port = get_free_port() self.url = f'http://127.0.0.1:{self.port}' self.chrome_args = [f'--remote-debugging-port={self.port}'] self._loop = self.options.get('loop', asyncio.get_event_loop()) logLevel = self.options.get('logLevel') if logLevel: logging.getLogger('pyppeteer').setLevel(logLevel) self.chromeClosed = True if self.options.get('appMode', False): self.options['headless'] = False self._tmp_user_data_dir = None self._parse_args() if self.options.get('devtools'): self.chrome_args.append('--auto-open-devtools-for-tabs') self.options['headless'] = False if 'headless' not in self.options or self.options.get('headless'): self.chrome_args.extend([ '--headless', '--disable-gpu', '--hide-scrollbars', '--mute-audio', ]) if 'executablePath' in self.options: self.exec = self.options['executablePath'] else: if not check_chromium(): download_chromium() self.exec = str(chromium_excutable()) self.cmd = [self.exec] + self.chrome_args
def __init__(self, options: Dict[str, Any] = None, **kwargs: Any) -> None: """Make new launcher.""" self.options = merge_dict(options, kwargs) self.port = get_free_port() self.url = f'http://127.0.0.1:{self.port}' self.chrome_args = DEFAULT_ARGS self.chrome_args.append(f'--remote-debugging-port={self.port}', ) self.chromeClosed = True if self.options.get('appMode', False): self.options['headless'] = False else: self.chrome_args.extend(AUTOMATION_ARGS) self._tmp_user_data_dir: Optional[str] = None self._parse_args() if self.options.get('devtools'): self.chrome_args.append('--auto-open-devtools-for-tabs') self.options['headless'] = False if 'headless' not in self.options or self.options.get('headless'): self.chrome_args = self.chrome_args + [ '--headless', '--disable-gpu', '--hide-scrollbars', '--mute-audio', ] if 'executablePath' in self.options: self.exec = self.options['executablePath'] else: if not check_chromium(): download_chromium() self.exec = str(chromium_excutable()) self.cmd = [self.exec] + self.chrome_args
def __init__(self, options: Dict[(str, Any)] = None, **kwargs: Any) -> None: 'Make new launcher.' self.options = merge_dict(options, kwargs) self.port = get_free_port() self.url = ''.join(['http://127.0.0.1:', '{}'.format(self.port)]) self.chrome_args = [] if (not self.options.get('ignoreDefaultArgs', False)): self.chrome_args.extend(DEFAULT_ARGS) self.chrome_args.append(''.join( ['--remote-debugging-port=', '{}'.format(self.port)])) self.chromeClosed = True if self.options.get('appMode', False): self.options['headless'] = False elif (not self.options.get('ignoreDefaultArgs', False)): self.chrome_args.extend(AUTOMATION_ARGS) self._tmp_user_data_dir = None self._parse_args() if self.options.get('devtools'): self.chrome_args.append('--auto-open-devtools-for-tabs') self.options['headless'] = False if (('headless' not in self.options) or self.options.get('headless')): self.chrome_args.extend([ '--headless', '--disable-gpu', '--hide-scrollbars', '--mute-audio' ]) if ('executablePath' in self.options): self.exec = self.options['executablePath'] else: if (not check_chromium()): download_chromium() self.exec = str(chromium_excutable()) self.cmd = ([self.exec] + self.chrome_args)
def __init__(self, options: Dict[str, Any] = None, **kwargs: Any) -> None: """Make new launcher.""" global BROWSER_ID BROWSER_ID += 1 self.options = options or dict() self.options.update(kwargs) self.user_data_dir = (CHROME_PROFILIE_PATH / str(os.getpid()) / str(BROWSER_ID)) self.chrome_args = DEFAULT_ARGS + [ '--user-data-dir=' + shlex.quote(str(self.user_data_dir)), ] if 'headless' not in self.options or self.options.get('headless'): self.chrome_args = self.chrome_args + [ '--headless', '--disable-gpu', '--hide-scrollbars', '--mute-audio', ] if 'executablePath' in self.options: self.exec = self.options['executablePath'] else: if not check_chromium(): download_chromium() self.exec = str(chromium_excutable()) self.cmd = [self.exec] + self.chrome_args
def __init__( self, options: Dict[str, Any] = None, # noqa: C901 **kwargs: Any) -> None: """Make new launcher.""" self.options = merge_dict(options, kwargs) self.port = get_free_port() self.url = f'http://127.0.0.1:{self.port}' self.chrome_args: List[str] = [] self._loop = self.options.get('loop', asyncio.get_event_loop()) logLevel = self.options.get('logLevel') if logLevel: logging.getLogger('pyppeteer').setLevel(logLevel) if not self.options.get('ignoreDefaultArgs', False): self.chrome_args.extend(DEFAULT_ARGS) self.chrome_args.append(f'--remote-debugging-port={self.port}', ) self.chromeClosed = True if self.options.get('appMode', False): self.options['headless'] = False elif not self.options.get('ignoreDefaultArgs', False): self.chrome_args.extend(AUTOMATION_ARGS) self._tmp_user_data_dir: Optional[str] = None self._parse_args() if self.options.get('devtools'): self.chrome_args.append('--auto-open-devtools-for-tabs') self.options['headless'] = False if 'headless' not in self.options or self.options.get('headless'): self.chrome_args.extend([ '--headless', '--disable-gpu', '--hide-scrollbars', '--mute-audio', ]) def _is_default_url() -> bool: for arg in self.options['args']: if not arg.startswith('-'): return False return True if (not self.options.get('ignoreDefaultArgs') and isinstance(self.options.get('args'), list) and _is_default_url()): self.chrome_args.append('about:blank') if 'executablePath' in self.options: self.exec = self.options['executablePath'] else: if not check_chromium(): download_chromium() self.exec = str(chromium_excutable()) self.cmd = [self.exec] + self.chrome_args
def __init__(self, options: Dict[str, Any] = None, # noqa: C901 **kwargs: Any) -> None: """Make new launcher.""" self.options = merge_dict(options, kwargs) self.port = get_free_port() self.url = f'http://127.0.0.1:{self.port}' self.chrome_args: List[str] = [] if not self.options.get('ignoreDefaultArgs', False): self.chrome_args.extend(DEFAULT_ARGS) self.chrome_args.append( f'--remote-debugging-port={self.port}', ) self.chromeClosed = True if self.options.get('appMode', False): self.options['headless'] = False elif not self.options.get('ignoreDefaultArgs', False): self.chrome_args.extend(AUTOMATION_ARGS) self._tmp_user_data_dir: Optional[str] = None self._parse_args() if self.options.get('devtools'): self.chrome_args.append('--auto-open-devtools-for-tabs') self.options['headless'] = False if 'headless' not in self.options or self.options.get('headless'): self.chrome_args.extend([ '--headless', '--disable-gpu', '--hide-scrollbars', '--mute-audio', ]) if 'executablePath' in self.options: self.exec = self.options['executablePath'] else: if not check_chromium(): download_chromium() self.exec = str(chromium_excutable()) self.cmd = [self.exec] + self.chrome_args
def __init__(self, options: Dict[str, Any] = None, **kwargs: Any) -> None: """Make new launcher.""" self.options = options or dict() self.options.update(kwargs) self.chrome_args = DEFAULT_ARGS self._tmp_user_data_dir: Optional[str] = None self._parse_args() if 'headless' not in self.options or self.options.get('headless'): self.chrome_args = self.chrome_args + [ '--headless', '--disable-gpu', '--hide-scrollbars', '--mute-audio', ] if 'executablePath' in self.options: self.exec = self.options['executablePath'] else: if not check_chromium(): download_chromium() self.exec = str(chromium_excutable()) self.cmd = [self.exec] + self.chrome_args
def executablePath() -> str: """Get executable path of default chrome.""" return str(chromium_excutable())
def executablePath() -> str: """Get executable path of default chrome.""" return str(chromium_excutable())