Skip to content

Commit

Permalink
Make SSL certificate verification optional
Browse files Browse the repository at this point in the history
  • Loading branch information
James McKinney authored and dracos committed May 15, 2015
1 parent 1338b44 commit 3d4988b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion speeches/importers/import_akomantoso.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ImportAkomaNtoso(ImporterBase):

def import_document(self, document_path):
if document_path.startswith('http'):
self.xml = objectify.fromstring(requests.get(document_path).content)
self.xml = objectify.fromstring(requests.get(document_path, verify=self.verify).content)
else:
self.xml = objectify.parse(document_path).getroot()
self.ns = self.xml.nsmap.get(None, None)
Expand Down
5 changes: 3 additions & 2 deletions speeches/importers/import_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
logger = logging.getLogger(__name__)


class ImporterBase (object):
def __init__(self, instance=None, commit=True, clobber=None, **kwargs):
class ImporterBase(object):
def __init__(self, instance=None, commit=True, clobber=None, verify=True, **kwargs):
self.instance = instance
self.commit = commit
self.clobber = clobber
self.verify = verify
self.speakers = {}

self.stats = {}
Expand Down
3 changes: 3 additions & 0 deletions speeches/management/import_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class ImportCommand(BaseCommand):
make_option('--instance', action='store', help='Label of instance to add data to'),
make_option('--file', action='store', help='document to import'),
make_option('--dir', action='store', help='directory of documents to import'),
make_option(
'--no-verify', action='store_false', default=True, dest='verify',
help='Whether to verify SSL certificates or not'),
make_option(
'--start-date', action='store', default='',
help='earliest date to process, in yyyy-mm-dd format'),
Expand Down
2 changes: 1 addition & 1 deletion speeches/tests/importer_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class FakeRequestsOutput(object):
def __init__(self, source):
def __init__(self, source, verify=True):
assert source.startswith('http://example.com/')

# We'll put things that would have been served from a url ending
Expand Down

0 comments on commit 3d4988b

Please sign in to comment.