# Buggy code
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.
    """
    from conda.utils import shells

    try:
        makedirs(dirname(dst))
    except OSError as exc:  # Python >2.5
        if exc.errno == EEXIST and isdir(dirname(dst)):
            pass
        else:
            raise

    # bat file redirect
    if not isfile(dst + ".bat"):
        with open(dst + ".bat", "w") as f:
            f.write('@echo off\ncall "%s" %%*\n' % src)

    # TODO: probably need one here for powershell at some point

    # This one is for bash/cygwin/msys
    # set default shell to bash.exe when not provided, as that's most common
    if not shell:
        shell = "bash.exe"

    # technically these are "links" - but islink doesn't work on win
    if not isfile(dst):
        with open(dst, "w") as f:
            f.write("#!/usr/bin/env bash \n")
            if src.endswith("conda"):
                f.write('%s "$@"' % shells[shell]["path_to"](src + ".exe"))
            else:
                f.write('source %s "$@"' % shells[shell]["path_to"](src))
        # Make the new file executable
        # http://stackoverflow.com/a/30463972/1170370
        mode = stat(dst).st_mode
        mode |= (mode & 292) >> 2  # copy R bits to X
        chmod(dst, mode)


# Traceback (ImportError)
$ conda -h
An unexpected error has occurred.
Please consider posting the following information to the
conda GitHub issue tracker at:

https://github.com/conda/conda/issues



Traceback (most recent call last):
File "/home/vmrguser/anaconda2/bin/conda", line 6, in <module>
sys.exit(conda.cli.main())
File "/home/vmrguser/anaconda2/lib/python2.7/site-packages/conda/cli/main.py", line 164, in main
return conda_exception_handler(_main, *args)
File "/home/vmrguser/anaconda2/lib/python2.7/site-packages/conda/exceptions.py", line 589, in conda_exception_handler
print_unexpected_error_message(e)
File "/home/vmrguser/anaconda2/lib/python2.7/site-packages/conda/exceptions.py", line 543, in print_unexpected_error_message
info_stdout, info_stderr = get_info()
File "/home/vmrguser/anaconda2/lib/python2.7/site-packages/conda/exceptions.py", line 513, in get_info
args.func(args, p)
File "/home/vmrguser/anaconda2/lib/python2.7/site-packages/conda/cli/main_info.py", line 148, in execute
from conda.api import get_index
File "/home/vmrguser/anaconda2/lib/python2.7/site-packages/conda/api.py", line 1, in <module>
from .core.index import get_index
File "/home/vmrguser/anaconda2/lib/python2.7/site-packages/conda/core/index.py", line 9, in <module>
from .repodata import collect_all_repodata
File "/home/vmrguser/anaconda2/lib/python2.7/site-packages/conda/core/repodata.py", line 21, in <module>
from requests.packages.urllib3.exceptions import InsecureRequestWarning
ImportError: No module named packages.urllib3.exceptions

# Fixed code
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.
    """
    from .utils import shells

    try:
        makedirs(dirname(dst))
    except OSError as exc:  # Python >2.5
        if exc.errno == EEXIST and isdir(dirname(dst)):
            pass
        else:
            raise

    # bat file redirect
    if not isfile(dst + ".bat"):
        with open(dst + ".bat", "w") as f:
            f.write('@echo off\ncall "%s" %%*\n' % src)

    # TODO: probably need one here for powershell at some point

    # This one is for bash/cygwin/msys
    # set default shell to bash.exe when not provided, as that's most common
    if not shell:
        shell = "bash.exe"

    # technically these are "links" - but islink doesn't work on win
    if not isfile(dst):
        with open(dst, "w") as f:
            f.write("#!/usr/bin/env bash \n")
            if src.endswith("conda"):
                f.write('%s "$@"' % shells[shell]["path_to"](src + ".exe"))
            else:
                f.write('source %s "$@"' % shells[shell]["path_to"](src))
        # Make the new file executable
        # http://stackoverflow.com/a/30463972/1170370
        mode = stat(dst).st_mode
        mode |= (mode & 292) >> 2  # copy R bits to X
        chmod(dst, mode)