Пример #1
0
def test_path_translations():
    paths = [
        (r";z:\miniconda\Scripts\pip.exe", ":/z/miniconda/Scripts/pip.exe", ":/cygdrive/z/miniconda/Scripts/pip.exe"),
        (
            r";z:\miniconda;z:\Documents (x86)\pip.exe;C:\test",
            ":/z/miniconda:/z/Documents (x86)/pip.exe:/C/test",
            ":/cygdrive/z/miniconda:/cygdrive/z/Documents (x86)/pip.exe:/cygdrive/C/test",
        ),
        # Failures:
        # (r"z:\miniconda\Scripts\pip.exe",
        #  "/z/miniconda/Scripts/pip.exe",
        #  "/cygdrive/z/miniconda/Scripts/pip.exe"),
        # ("z:\\miniconda\\",
        #  "/z/miniconda/",
        #  "/cygdrive/z/miniconda/"),
        (
            "test dummy text /usr/bin;z:\\documents (x86)\\code\\conda\\tests\\envskhkzts\\test1;z:\\documents\\code\\conda\\tests\\envskhkzts\\test1\\cmd more dummy text",
            "test dummy text /usr/bin:/z/documents (x86)/code/conda/tests/envskhkzts/test1:/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text",
            "test dummy text /usr/bin:/cygdrive/z/documents (x86)/code/conda/tests/envskhkzts/test1:/cygdrive/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text",
        ),
    ]
    for windows_path, unix_path, cygwin_path in paths:
        assert utils.win_path_to_unix(windows_path) == unix_path
        assert utils.unix_path_to_win(unix_path) == windows_path

        assert utils.win_path_to_cygwin(windows_path) == cygwin_path
        assert utils.cygwin_path_to_win(cygwin_path) == windows_path
Пример #2
0
def test_path_translations():
    paths = [
        (r";z:\miniconda\Scripts\pip.exe", ":/z/miniconda/Scripts/pip.exe",
         ":/cygdrive/z/miniconda/Scripts/pip.exe"),
        (r";z:\miniconda;z:\Documents (x86)\pip.exe;C:\test",
         ":/z/miniconda:/z/Documents (x86)/pip.exe:/C/test",
         ":/cygdrive/z/miniconda:/cygdrive/z/Documents (x86)/pip.exe:/cygdrive/C/test"
         ),
        # Failures:
        # (r"z:\miniconda\Scripts\pip.exe",
        #  "/z/miniconda/Scripts/pip.exe",
        #  "/cygdrive/z/miniconda/Scripts/pip.exe"),

        # ("z:\\miniconda\\",
        #  "/z/miniconda/",
        #  "/cygdrive/z/miniconda/"),
        ("test dummy text /usr/bin;z:\\documents (x86)\\code\\conda\\tests\\envskhkzts\\test1;z:\\documents\\code\\conda\\tests\\envskhkzts\\test1\\cmd more dummy text",
         "test dummy text /usr/bin:/z/documents (x86)/code/conda/tests/envskhkzts/test1:/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text",
         "test dummy text /usr/bin:/cygdrive/z/documents (x86)/code/conda/tests/envskhkzts/test1:/cygdrive/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text"
         ),
    ]
    for windows_path, unix_path, cygwin_path in paths:
        assert utils.win_path_to_unix(windows_path) == unix_path
        assert utils.unix_path_to_win(unix_path) == windows_path

        assert utils.win_path_to_cygwin(windows_path) == cygwin_path
        assert utils.cygwin_path_to_win(cygwin_path) == windows_path
Пример #3
0
def test_path_translation():
    test_cygwin_path = "test dummy text /usr/bin:/cygdrive/z/documents (x86)/code/conda/tests/envskhkzts/test1:/cygdrive/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text"
    test_unix_path = "test dummy text /usr/bin:/z/documents (x86)/code/conda/tests/envskhkzts/test1:/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text"
    test_win_path = "test dummy text /usr/bin;z:\\documents (x86)\\code\\conda\\tests\\envskhkzts\\test1;z:\\documents\\code\\conda\\tests\\envskhkzts\\test1\\cmd more dummy text"
    assert_equals(test_win_path, unix_path_to_win(test_unix_path))
    assert_equals(test_unix_path, win_path_to_unix(test_win_path))
    assert_equals(test_cygwin_path, win_path_to_cygwin(test_win_path))
    assert_equals(test_win_path, cygwin_path_to_win(test_cygwin_path))
Пример #4
0
def test_path_translation():
    test_cygwin_path = "test dummy text /usr/bin:/cygdrive/z/documents (x86)/code/conda/tests/envskhkzts/test1:/cygdrive/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text"
    test_unix_path = "test dummy text /usr/bin:/z/documents (x86)/code/conda/tests/envskhkzts/test1:/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text"
    test_win_path = "test dummy text /usr/bin;z:\\documents (x86)\\code\\conda\\tests\\envskhkzts\\test1;z:\\documents\\code\\conda\\tests\\envskhkzts\\test1\\cmd more dummy text"
    assert_equals(test_win_path, unix_path_to_win(test_unix_path))
    assert_equals(test_unix_path, win_path_to_unix(test_win_path))
    assert_equals(test_cygwin_path, win_path_to_cygwin(test_win_path))
    assert_equals(test_win_path, cygwin_path_to_win(test_cygwin_path))
Пример #5
0
    def win_conda_bat_redirect(src, dst, shell):
        """Special function for Windows XP where the `CreateSymbolicLink`
        function is not available.

        Simply creates a `.bat` file at `dst` which calls `src` together with
        all command line arguments.

        Works of course only with callable files, e.g. `.bat` or `.exe` files.
        """
        try:
            os.makedirs(os.path.dirname(dst))
        except OSError as exc:  # Python >2.5
            if exc.errno == errno.EEXIST and os.path.isdir(
                    os.path.dirname(dst)):
                pass
            else:
                raise

        if 'cmd.exe' in shell.lower():
            # bat file redirect
            with open(dst + '.bat', 'w') as f:
                f.write('@echo off\n"%s" %%*\n' % src)

        elif 'powershell' in shell.lower():
            # TODO: probably need one here for powershell at some point
            pass

        else:
            # This one is for bash/cygwin/msys
            if src.endswith("conda"):
                src = src + ".exe"

            path_prefix = ""
            if 'cygwin' in shell.lower():
                path_prefix = '/cygdrive'

            src = win_path_to_unix(src, path_prefix)
            dst = win_path_to_unix(dst, path_prefix)

            subprocess.check_call(
                ["bash", "-l", "-c",
                 'ln -sf "%s" "%s"' % (src, dst)])
Пример #6
0
    def win_conda_bat_redirect(src, dst, shell):
        """Special function for Windows XP where the `CreateSymbolicLink`
        function is not available.

        Simply creates a `.bat` file at `dst` which calls `src` together with
        all command line arguments.

        Works of course only with callable files, e.g. `.bat` or `.exe` files.
        """
        try:
            os.makedirs(os.path.dirname(dst))
        except OSError as exc:  # Python >2.5
            if exc.errno == errno.EEXIST and os.path.isdir(os.path.dirname(dst)):
                pass
            else:
                raise

        if 'cmd.exe' in shell.lower():
            # bat file redirect
            with open(dst+'.bat', 'w') as f:
                f.write('@echo off\n"%s" %%*\n' % src)

        elif 'powershell' in shell.lower():
            # TODO: probably need one here for powershell at some point
            pass

        else:
            # This one is for bash/cygwin/msys
            if src.endswith("conda"):
                src = src + ".exe"

            path_prefix = ""
            if 'cygwin' in shell.lower():
                path_prefix = '/cygdrive'

            src = win_path_to_unix(src, path_prefix)
            dst = win_path_to_unix(dst, path_prefix)

            subprocess.check_call(["bash", "-l", "-c",
                                   'ln -sf "%s" "%s"' % (src, dst)])
Пример #7
0
def test_path_translations():
    paths = [
        (r";z:\miniconda\Scripts\pip.exe",
         ":/z/miniconda/Scripts/pip.exe",
         ":/cygdrive/z/miniconda/Scripts/pip.exe"),
        (r";z:\miniconda;z:\Documents (x86)\pip.exe;C:\test",
         ":/z/miniconda:/z/Documents (x86)/pip.exe:/C/test",
         ":/cygdrive/z/miniconda:/cygdrive/z/Documents (x86)/pip.exe:/cygdrive/C/test"),
        # Failures:
        # (r"z:\miniconda\Scripts\pip.exe",
        #  "/z/miniconda/Scripts/pip.exe",
        #  "/cygdrive/z/miniconda/Scripts/pip.exe"),

        # ("z:\\miniconda\\",
        #  "/z/miniconda/",
        #  "/cygdrive/z/miniconda/"),
        ("test dummy text /usr/bin;z:\\documents (x86)\\code\\conda\\tests\\envskhkzts\\test1;z:\\documents\\code\\conda\\tests\\envskhkzts\\test1\\cmd more dummy text",
        "test dummy text /usr/bin:/z/documents (x86)/code/conda/tests/envskhkzts/test1:/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text",
        "test dummy text /usr/bin:/cygdrive/z/documents (x86)/code/conda/tests/envskhkzts/test1:/cygdrive/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text"),
    ]
    for windows_path, unix_path, cygwin_path in paths:
        win2unix = utils.win_path_to_unix(windows_path)
        unix2win = utils.unix_path_to_win(unix_path)

        win2cygwin = utils.win_path_to_cygwin(windows_path)
        cygwin2win = utils.cygwin_path_to_win(cygwin_path)

        print("win2unix == unix_path :: {} == {} :: {}".format(
            win2unix,
            unix_path,
            win2unix == unix_path))
        print("unix2win == windows_path :: {} == {} :: {}".format(
            unix2win,
            windows_path,
            unix2win == windows_path))

        print("win2cygwin == cygwin_path :: {} == {} :: {}".format(
            win2cygwin,
            cygwin_path,
            win2cygwin == cygwin_path))
        print("cygwin2win == windows_path :: {} == {} :: {}".format(
            cygwin2win,
            windows_path,
            cygwin2win == windows_path))

        assert win2unix == unix_path
        assert unix2win == windows_path

        assert win2cygwin == cygwin_path
        assert cygwin2win == windows_path
Пример #8
0
def test_path_translations():
    paths = [
        (r";z:\miniconda\Scripts\pip.exe", ":/z/miniconda/Scripts/pip.exe",
         ":/cygdrive/z/miniconda/Scripts/pip.exe"),
        (r";z:\miniconda;z:\Documents (x86)\pip.exe;C:\test",
         ":/z/miniconda:/z/Documents (x86)/pip.exe:/C/test",
         ":/cygdrive/z/miniconda:/cygdrive/z/Documents (x86)/pip.exe:/cygdrive/C/test"
         ),
        # Failures:
        # (r"z:\miniconda\Scripts\pip.exe",
        #  "/z/miniconda/Scripts/pip.exe",
        #  "/cygdrive/z/miniconda/Scripts/pip.exe"),

        # ("z:\\miniconda\\",
        #  "/z/miniconda/",
        #  "/cygdrive/z/miniconda/"),
        ("test dummy text /usr/bin;z:\\documents (x86)\\code\\conda\\tests\\envskhkzts\\test1;z:\\documents\\code\\conda\\tests\\envskhkzts\\test1\\cmd more dummy text",
         "test dummy text /usr/bin:/z/documents (x86)/code/conda/tests/envskhkzts/test1:/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text",
         "test dummy text /usr/bin:/cygdrive/z/documents (x86)/code/conda/tests/envskhkzts/test1:/cygdrive/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text"
         ),
    ]
    for windows_path, unix_path, cygwin_path in paths:
        win2unix = utils.win_path_to_unix(windows_path)
        unix2win = utils.unix_path_to_win(unix_path)

        win2cygwin = utils.win_path_to_cygwin(windows_path)
        cygwin2win = utils.cygwin_path_to_win(cygwin_path)

        print("win2unix == unix_path :: {} == {} :: {}".format(
            win2unix, unix_path, win2unix == unix_path))
        print("unix2win == windows_path :: {} == {} :: {}".format(
            unix2win, windows_path, unix2win == windows_path))

        print("win2cygwin == cygwin_path :: {} == {} :: {}".format(
            win2cygwin, cygwin_path, win2cygwin == cygwin_path))
        print("cygwin2win == windows_path :: {} == {} :: {}".format(
            cygwin2win, windows_path, cygwin2win == windows_path))

        assert win2unix == unix_path
        assert unix2win == windows_path

        assert win2cygwin == cygwin_path
        assert cygwin2win == windows_path
Пример #9
0
def test_text_translations():
    test_win_text = "prepending z:\\msarahan\\code\\conda\\tests\\envsk5_b4i\\test 1 and z:\\msarahan\\code\\conda\\tests\\envsk5_b4i\\test 1\\scripts to path"
    test_unix_text = "prepending /z/msarahan/code/conda/tests/envsk5_b4i/test 1 and /z/msarahan/code/conda/tests/envsk5_b4i/test 1/scripts to path"
    assert_equals(test_win_text, utils.unix_path_to_win(test_unix_text))
    assert_equals(test_unix_text, utils.win_path_to_unix(test_win_text))
Пример #10
0
def test_text_translations():
    test_win_text = "prepending z:\\msarahan\\code\\conda\\tests\\envsk5_b4i\\test 1 and z:\\msarahan\\code\\conda\\tests\\envsk5_b4i\\test 1\\scripts to path"
    test_unix_text = "prepending /z/msarahan/code/conda/tests/envsk5_b4i/test 1 and /z/msarahan/code/conda/tests/envsk5_b4i/test 1/scripts to path"
    assert_equals(test_win_text, utils.unix_path_to_win(test_unix_text))
    assert_equals(test_unix_text, utils.win_path_to_unix(test_win_text))