Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make having requests not installed a runtime error only on the comman…

…ds that use it.
  • Loading branch information...
commit b9a61800d652668bb774cd9729f0f9f44578a393 1 parent 5189b64
@ralsina authored
View
10 nikola/plugins/command_bootswatch_theme.py
@@ -25,7 +25,11 @@
from __future__ import print_function
from optparse import OptionParser
import os
-import requests
+
+try:
+ import requests
+except ImportError:
+ requests = None
from nikola.plugin_categories import Command
@@ -37,7 +41,9 @@ class CommandBootswatchTheme(Command):
def run(self, *args):
"""Given a swatch name and a parent theme, creates a custom theme."""
-
+ if requests is None:
+ print('To use the install_theme command, you need to install the "requests" package.')
+ return
parser = OptionParser(usage="nikola %s [options]" % self.name)
parser.add_option("-n", "--name", dest="name",
help="New theme name (default: custom)", default='custom')
View
9 nikola/plugins/command_import_wordpress.py
@@ -34,7 +34,11 @@
from lxml import etree, html, builder
from mako.template import Template
-import requests
+
+try:
+ import requests
+except ImportError:
+ requests = None
from nikola.plugin_categories import Command
from nikola import utils
@@ -244,6 +248,9 @@ def write_configuration(filename, rendered_template):
def run(self, fname=None):
# Parse the data
+ if requests is None:
+ print('To use the import_wordpress command, you have to install the "requests" package.')
+ return
if fname is None:
print("Usage: nikola import_wordpress wordpress_dump.xml")
return
View
10 nikola/plugins/command_install_theme.py
@@ -25,10 +25,14 @@
from __future__ import print_function
from optparse import OptionParser
import os
-import requests
import json
from io import StringIO
+try:
+ import requests
+except ImportError:
+ requests = None
+
from nikola.plugin_categories import Command
from nikola import utils
@@ -40,7 +44,9 @@ class CommandInstallTheme(Command):
def run(self, *args):
"""Install theme into current site."""
-
+ if requests is None:
+ print('To use the install_theme command, you need to install the "requests" package.')
+ return
parser = OptionParser(usage="nikola %s [options]" % self.name)
parser.add_option("-l", "--list", dest="list",
action="store_true",
View
1  setup.py
@@ -38,7 +38,6 @@
'lxml',
'yapsy',
'mock>=1.0.0',
- 'requests',
'markdown',
'Jinja2',
]
Please sign in to comment.
Something went wrong with that request. Please try again.