# Buggy code
def _execute(self, options, args):
    """Given a swatch name and a parent theme, creates a custom theme."""
    if requests is None:
        utils.req_missing(["requests"], "install Bootswatch themes")

    name = options["name"]
    swatch = options["swatch"]
    parent = options["parent"]
    version = ""

    # See if we need bootswatch for bootstrap v2 or v3
    themes = utils.get_theme_chain(parent)
    if "bootstrap3" not in themes:
        version = "2"
    elif "bootstrap" not in themes:
        LOGGER.warn('"bootswatch_theme" only makes sense for themes that use bootstrap')
    elif "bootstrap3-gradients" in themes or "bootstrap3-gradients-jinja" in themes:
        LOGGER.warn(
            '"bootswatch_theme" doesn\'t work well with the bootstrap3-gradients family'
        )

    LOGGER.info(
        "Creating '{0}' theme from '{1}' and '{2}'".format(name, swatch, parent)
    )
    utils.makedirs(os.path.join("themes", name, "assets", "css"))
    for fname in ("bootstrap.min.css", "bootstrap.css"):
        url = "/".join(("http://bootswatch.com", version, swatch, fname))
        LOGGER.info("Downloading: " + url)
        data = requests.get(url).text
        with open(
            os.path.join("themes", name, "assets", "css", fname), "wb+"
        ) as output:
            output.write(data.encode("utf-8"))

    with open(os.path.join("themes", name, "parent"), "wb+") as output:
        output.write(parent.encode("utf-8"))
    LOGGER.notice(
        'Theme created.  Change the THEME setting to "{0}" to use it.'.format(name)
    )


# Traceback (ConnectionError)
[2014-04-04T14:54:00Z] INFO: bootswatch_theme: Creating 'custom' theme from 'cerulean' and 'bootstrap3'
[2014-04-04T14:54:00Z] INFO: bootswatch_theme: Downloading: http://bootswatch.com//cerulean/bootstrap.min.css
Traceback (most recent call last):
File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/doit/doit_cmd.py", line 105, in run
return self.sub_cmds[command].parse_execute(args)
File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/doit/cmd_base.py", line 76, in parse_execute
return self.execute(params, args)
File "/home/kwpolska/git/nikola/scripts/../nikola/plugin_categories.py", line 104, in execute
self._execute(options, args)
File "/home/kwpolska/git/nikola/nikola/plugins/command/bootswatch_theme.py", line 97, in _execute
data = requests.get(url).text
File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/requests/api.py", line 55, in get
return request('get', url, **kwargs)
File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/requests/sessions.py", line 383, in request
resp = self.send(prep, **send_kwargs)
File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/requests/sessions.py", line 506, in send
history = [resp for resp in gen] if allow_redirects else []
File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/requests/sessions.py", line 168, in resolve_redirects
allow_redirects=False,
File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/requests/sessions.py", line 486, in send
r = adapter.send(request, **kwargs)
File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/requests/adapters.py", line 378, in send
raise ConnectionError(e)
ConnectionError: HTTPConnectionPool(host=u'cerulean', port=80): Max retries exceeded with url: /bootstrap.min.css (Caused by <class 'socket.gaierror'>: [Errno -2] Name or service not known)

# Fixed code
def _execute(self, options, args):
    """Given a swatch name and a parent theme, creates a custom theme."""
    if requests is None:
        utils.req_missing(["requests"], "install Bootswatch themes")

    name = options["name"]
    swatch = options["swatch"]
    parent = options["parent"]
    version = ""

    # See if we need bootswatch for bootstrap v2 or v3
    themes = utils.get_theme_chain(parent)
    if "bootstrap3" not in themes:
        version = "2"
    elif "bootstrap" not in themes:
        LOGGER.warn('"bootswatch_theme" only makes sense for themes that use bootstrap')
    elif "bootstrap3-gradients" in themes or "bootstrap3-gradients-jinja" in themes:
        LOGGER.warn(
            '"bootswatch_theme" doesn\'t work well with the bootstrap3-gradients family'
        )

    LOGGER.info(
        "Creating '{0}' theme from '{1}' and '{2}'".format(name, swatch, parent)
    )
    utils.makedirs(os.path.join("themes", name, "assets", "css"))
    for fname in ("bootstrap.min.css", "bootstrap.css"):
        url = "http://bootswatch.com"
        if version:
            url += "/" + version
        url = "/".join((url, swatch, fname))
        LOGGER.info("Downloading: " + url)
        data = requests.get(url).text
        with open(
            os.path.join("themes", name, "assets", "css", fname), "wb+"
        ) as output:
            output.write(data.encode("utf-8"))

    with open(os.path.join("themes", name, "parent"), "wb+") as output:
        output.write(parent.encode("utf-8"))
    LOGGER.notice(
        'Theme created.  Change the THEME setting to "{0}" to use it.'.format(name)
    )