示例#1
0
def find_msys_version_subdir(msys_dir):
    """Return the full MSYS root directory path

    If msys_dir path lacks the version subdirectory, e.g. 1.0, then the
    path is searched for one. The user will be prompted to choose if more
    than one version is found.
    """

    regex = r'[\\/][1-9][.][0-9]$'
    if re.search(regex, msys_dir) is not None:
        return msys_dir
    
    roots = glob.glob(os.path.join(msys_dir, '[1-9].[0-9]'))
    roots.sort()
    roots.reverse()
    if not roots:
        raise MsysException("No msys versions found.\n")
    else:
        if len(roots) == 1:
            root = roots[0]
        else:
            msys_print("Select an Msys version:")
            for i, path in enumerate(roots):
                msys_print("  %d = %s" % (i+1, os.path.split(path)[1]))
            choice = msys_raw_input("Select 1-%d (1 = default):")
            if not choice:
                root = roots[0]
            else:
                root = roots[int(choice)-1]
        return root
示例#2
0
def input_msys_dir():
    """Return user entered MSYS directory path

    May raise MsysException."""

    while 1:
        dir_path = msys_raw_input("Enter the MSYS directory path,\n"
                              "(or press [Enter] to quit):")
        dir_path = dir_path.strip()
        if not dir_path:
            raise MsysException("Input aborted by user")
        dir_path = os.path.abspath(dir_path)
        try:
            return find_msys_version_subdir(dir_path)
        except MsysException:
            msys_print(helpers.geterror ())