diff --git a/speeches/importers/import_akomantoso.py b/speeches/importers/import_akomantoso.py index 707355b7..63886999 100644 --- a/speeches/importers/import_akomantoso.py +++ b/speeches/importers/import_akomantoso.py @@ -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) diff --git a/speeches/importers/import_base.py b/speeches/importers/import_base.py index 9026b600..70fd482f 100644 --- a/speeches/importers/import_base.py +++ b/speeches/importers/import_base.py @@ -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 = {} diff --git a/speeches/management/import_commands.py b/speeches/management/import_commands.py index 02e1a64a..30318f84 100644 --- a/speeches/management/import_commands.py +++ b/speeches/management/import_commands.py @@ -24,6 +24,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'), diff --git a/speeches/tests/importer_tests.py b/speeches/tests/importer_tests.py index 6c7f27bb..12a325bc 100644 --- a/speeches/tests/importer_tests.py +++ b/speeches/tests/importer_tests.py @@ -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