mokr.download ============= .. py:module:: mokr.download Attributes ---------- .. autoapisummary:: mokr.download.CHROME_DL_HOST mokr.download.FIREFOX_DL_HOST mokr.download.CR_DOWNLOAD_URLS mokr.download.FF_DOWNLOAD_URLS mokr.download.CR_BINARY_NAMES mokr.download.FF_BINARY_NAMES mokr.download.CR_BINARY_PATHS mokr.download.FF_BINARY_PATHS Functions --------- .. autoapisummary:: mokr.download.get_platform mokr.download.download_zip mokr.download.browser_binary mokr.download.ensure_binary mokr.download.install_dmg mokr.download.extract mokr.download.install_binary Module Contents --------------- .. py:data:: CHROME_DL_HOST .. py:data:: FIREFOX_DL_HOST .. py:data:: CR_DOWNLOAD_URLS .. py:data:: FF_DOWNLOAD_URLS .. py:data:: CR_BINARY_NAMES .. py:data:: FF_BINARY_NAMES .. py:data:: CR_BINARY_PATHS .. py:data:: FF_BINARY_PATHS .. py:function:: get_platform() -> str Small utility to get different URL for MacOS Silicon machines. .. py:function:: download_zip(browser_type: str, url: str) -> io.BytesIO Download browser from the given `url`. :param browser_type: Target browser type, of "chrome" or "firefox". :type browser_type: str :param url: URL to download from. :type url: str :raises requests.HTTPError: Raised if response is bad (status code over 399). :returns: The browser content as a BytesIO object. :rtype: BytesIO .. py:function:: browser_binary(browser_type: str) -> pathlib.Path Get path of the system target browser binary. :param browser_type: Target browser type, of "chrome" or "firefox". :type browser_type: str :returns: Browser binary Path object. :rtype: Path .. py:function:: ensure_binary(browser_type: str) -> bool Ensure the target browser exists on this machine. :param browser_type: Target browser type, of "chrome" or "firefox". :type browser_type: str :returns: True if binary exists, otherwise False. :rtype: bool .. py:function:: install_dmg(process_bar: tqdm.tqdm, dmg_path: str, dest_path: pathlib.Path) -> None Install browser from dmg file. Mounts the dmg and copies to target path. :param process_bar: A process bar to update as actions occur. :type process_bar: tqdm :param dmg_path: Path to dmg file. :type dmg_path: str :param dest_path: Path to final directory. :type dest_path: Path :raises OSError: Raised if mount fails. :raises FileNotFoundError: Raised if dmg contains no .app files. .. py:function:: extract(browser_type: str, data: io.BytesIO, path: pathlib.Path, url: str) -> None Extract given loaded zip file to target `path`. :param browser_type: Target browser type, of "chrome" or "firefox". :type browser_type: str :param data: Zip file as BytesIO. :type data: BytesIO :param path: Destination path to extract to. :type path: Path :param url: Download URL the file came from. :type url: str :raises IOError: Raised if an unhandled error occurs and the browser simply doesn't end up extracted to the target. .. py:function:: install_binary(browser_type: str) -> None Download and extract binary. :param browser_type: Target browser type, of "chrome" or "firefox". :type browser_type: str