Esempio n. 1
0
def get_wine_mono_download_link_from_github() -> str:
    """
    >>> get_wine_mono_download_link_from_github()  # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
    'https://github.com//madewokherd/wine-mono/releases/download/wine-mono-.../wine-mono-...msi'
    """
    filename = configmagick_linux.get_path_home_dir_current_user(
    ) / 'mono-latest-release.html'
    try:
        download_link = 'https://github.com/madewokherd/wine-mono/releases/latest'
        configmagick_linux.download_file(download_link=download_link,
                                         filename=filename)
        link = lib_shell.run_shell_command(
            'fgrep ".msi" "{filename}" | fgrep "wine-mono" | fgrep "href="'.
            format(filename=filename),
            shell=True,
            quiet=True,
            use_sudo=True).stdout
        link = link.split('href="', 1)[1]
        link = 'https://github.com/' + link.split('"', 1)[0]
    finally:
        lib_shell.run_shell_command(
            'rm -f "{filename}"'.format(filename=filename),
            shell=True,
            quiet=True,
            use_sudo=True)
    return str(link)
Esempio n. 2
0
def download_file_to_winecache(download_link: str, filename: pathlib.Path, username: str) -> None:
    """
    >>> download_link = 'https://source.winehq.org/winemono.php?v=4.9.3'
    >>> filename = pathlib.Path('wine-mono-4.9.3.msi')
    >>> username = configmagick_linux.get_current_username()
    >>> download_file_to_winecache(download_link=download_link, filename=filename, username=username)
    >>> assert pathlib.Path( configmagick_linux.get_path_home_dir_current_user() / '.cache/wine/wine-mono-4.9.3.msi').is_file()

    """
    create_wine_cache_for_user(username=username)
    path_wine_cache = get_path_wine_cache_for_user(username=username)
    download_filename = path_wine_cache / filename
    configmagick_linux.download_file(download_link=download_link, filename=download_filename)
    fix_permissions_winecache(username=username)
def get_python_exe_backup_download_link(version: str,
                                        arch: str = 'win32') -> str:
    """ get the download link for the python version from the webpage to the python installer exe
    Parameter:
        version = '3.8.0'
        arch = 'win32' or 'win64'

    >>> import unittest
    >>> assert get_python_exe_backup_download_link(version='3.8.0', arch='win32') == 'https://www.python.org/ftp/python/3.8.0/python-3.8.0.exe'
    >>> assert get_python_exe_backup_download_link(version='3.8.0', arch='win64') == 'https://www.python.org/ftp/python/3.8.0/python-3.8.0-amd64.exe'
    >>> unittest.TestCase().assertRaises(RuntimeError, get_python_exe_backup_download_link, version='3.8.0', arch='invalid')    # invalid arch
    >>> unittest.TestCase().assertRaises(RuntimeError, get_python_exe_backup_download_link, version='3.1.9', arch='win32')      # invalid version

    """
    # noinspection PyBroadException
    arch = lib_wine.get_and_check_wine_arch_valid(arch)
    filename = configmagick_linux.get_path_home_dir_current_user(
    ) / 'python-latest-release.html'
    path_python_filename = get_path_python_exe_filename(version=version,
                                                        arch=arch)
    try:
        download_link = 'https://www.python.org/downloads/windows/'
        configmagick_linux.download_file(download_link=download_link,
                                         filename=filename)

        python_backup_download_link = lib_shell.run_shell_command(
            'fgrep "{path_python_filename}" "{filename}" | fgrep "href="'.
            format(filename=filename,
                   path_python_filename=path_python_filename),
            shell=True,
            quiet=True,
            use_sudo=True).stdout
        # <li>Download <a href="https://www.python.org/ftp/python/3.8.0/python-3.8.0-amd64.exe">Windows x86-64 executable installer</a></li>
        python_backup_download_link = python_backup_download_link.split(
            '<a href="')[1]
        # https://www.python.org/ftp/python/3.8.0/python-3.8.0-amd64.exe">Windows x86-64 executable installer</a></li>
        python_backup_download_link = python_backup_download_link.split(
            '"')[0].strip()
        # https://www.python.org/ftp/python/3.8.0/python-3.8.0-amd64.exe
    except Exception:
        raise RuntimeError(
            'can not get Download Link for Python {path_python_filename}'.
            format(path_python_filename=path_python_filename))
    finally:
        lib_shell.run_shell_command(
            'rm -f "{filename}"'.format(filename=filename),
            shell=True,
            quiet=True,
            use_sudo=True)
    return str(python_backup_download_link)
Esempio n. 4
0
def download_gecko_64_msi_files(wine_prefix: Union[str, pathlib.Path],
                                username: str,
                                quiet: bool = False) -> None:
    path_wine_cache_directory = lib_wine.get_path_wine_cache_for_user(username)
    path_gecko_64_msi_filename = get_gecko_64_filename_from_appwiz(
        wine_prefix, username)
    gecko_download_link = get_gecko_download_link(path_gecko_64_msi_filename)
    gecko_backup_download_link = get_gecko_backup_download_link(
        path_gecko_64_msi_filename)
    try:
        configmagick_linux.download_file(gecko_download_link,
                                         path_wine_cache_directory /
                                         path_gecko_64_msi_filename,
                                         use_sudo=True,
                                         quiet=quiet)
    except subprocess.CalledProcessError:
        configmagick_linux.download_file(gecko_backup_download_link,
                                         path_wine_cache_directory /
                                         path_gecko_64_msi_filename,
                                         use_sudo=True,
                                         quiet=quiet)
def get_latest_python_version() -> str:
    """ get latest Python3 Version as String, or '3.8.0' if can not determined

    Returns:
         "3.8.0" or whatever is the latest Version Number

    >>> version = get_latest_python_version()
    >>> assert '.' in version
    >>> assert get_latest_python_version().startswith('3')
    """
    # noinspection PyBroadException
    filename = configmagick_linux.get_path_home_dir_current_user(
    ) / 'python-latest-release.html'
    try:
        download_link = 'https://www.python.org/downloads/windows/'
        configmagick_linux.download_file(download_link=download_link,
                                         filename=filename)

        s_version = lib_shell.run_shell_command(
            'fgrep "Latest Python 3 Release" "{filename}" | fgrep "href="'.
            format(filename=filename),
            shell=True,
            quiet=True,
            use_sudo=True).stdout
        # <li><a href="/downloads/release/python-380/">Latest Python 3 Release - Python 3.8.0</a></li>
        s_version = s_version.rsplit('Latest Python 3 Release',
                                     1)[1]  # - Python 3.8.0</a></li>
        s_version = s_version.split('Python', 1)[1].strip()  # 3.8.0</a></li>
        s_version = s_version.split('</a>', 1)[0].strip()  # 3.8.0
    except Exception:
        lib_log_utils.log_warning(
            'can not determine latest Python Version, assuming Version 3.8.0')
        s_version = '3.8.0'
    finally:
        lib_shell.run_shell_command(
            'rm -f "{filename}"'.format(filename=filename),
            shell=True,
            quiet=True,
            use_sudo=True)
    return str(s_version)
Esempio n. 6
0
def get_git_portable_download_link_from_github(wine_arch: str) -> str:
    """
    Parameter:
        wine_arch = win32 or win64

    >>> get_git_portable_download_link_from_github(wine_arch='win32')  # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
    'https://github.com/git-for-windows/git/releases/download/v...windows.1/PortableGit-...-32-bit.7z.exe'

    >>> get_git_portable_download_link_from_github(wine_arch='win64')  # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
    'https://github.com/git-for-windows/git/releases/download/v...windows.1/PortableGit-...-64-bit.7z.exe'

    >>> get_git_portable_download_link_from_github(wine_arch='invalid')  # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
    Traceback (most recent call last):
        ...
    subprocess.CalledProcessError: ...

    """
    filename = configmagick_linux.get_path_home_dir_current_user(
    ) / 'git-latest-release.html'
    try:
        download_link = 'https://github.com/git-for-windows/git/releases/latest'
        configmagick_linux.download_file(download_link=download_link,
                                         filename=filename)
        link = lib_shell.run_shell_command(
            'fgrep "PortableGit-" "{filename}" | fgrep "{bit}-bit.7z.exe" | fgrep "href="'
            .format(filename=filename, bit=wine_arch[3:]),
            shell=True,
            quiet=True,
            use_sudo=True).stdout
        link = link.split('href="', 1)[1]
        link = 'https://github.com' + link.split('"', 1)[0]
    finally:
        lib_shell.run_shell_command(
            'rm -f "{filename}"'.format(filename=filename),
            shell=True,
            quiet=True,
            use_sudo=True)
    return str(link)