From 6820826e3a8120f5a02d53b35f06499b0e73f852 Mon Sep 17 00:00:00 2001 From: Florent Date: Thu, 8 May 2014 11:34:11 +0200 Subject: [PATCH] Do not crash if the subscription is closed --- modules/leclercmobile/browser.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/leclercmobile/browser.py b/modules/leclercmobile/browser.py index 0db18b76..e384ca6d 100644 --- a/modules/leclercmobile/browser.py +++ b/modules/leclercmobile/browser.py @@ -116,9 +116,11 @@ class Leclercmobile(BaseBrowser): if not self.is_on_page(HistoryPage): self.location(self.conso) response = self.openurl(self.bills + "0") - pdf = PdfPage(StringIO.StringIO(response.read())) - for detail in pdf.get_details(): - yield detail + mimetype = response.info().get('Content-Type', '').split(';')[0] + if mimetype == "application/pdf": + pdf = PdfPage(StringIO.StringIO(response.read())) + for detail in pdf.get_details(): + yield detail def iter_bills(self, parentid): if not self.is_on_page(HistoryPage):