Grigoriy Petukhov avatar Grigoriy Petukhov committed 97ea847

More correct handling of fatal parserin errors

Comments (0)

Files changed (1)

feedzilla/util/parse.py

         resp['feed'].last_checked = datetime.now()
 
     for entry in resp['feed'].entries:
-        link = getattr(entry, 'link', '')
+        try:
+            link = getattr(entry, 'link', '')
 
-        # Do not process entries without title
-        if not hasattr(entry, 'title'):
-            log.error('Post %s does not has a title' % link)
-            continue
+            # Do not process entries without title
+            if not hasattr(entry, 'title'):
+                log.error('Post %s does not has a title' % link)
+                continue
 
-        title = entry.title
+            title = entry.title
 
-        if hasattr(entry,'content'):
-            content = entry.content[0].value
-        elif hasattr(entry,'summary'):
-            content = entry.summary
-        elif hasattr(entry,'description'):
-            content = entry.description
-        else:
-            # Use title as fallback variant for the post's content
-            content = title
+            if hasattr(entry,'content'):
+                content = entry.content[0].value
+            elif hasattr(entry,'summary'):
+                content = entry.summary
+            elif hasattr(entry,'description'):
+                content = entry.description
+            else:
+                # Use title as fallback variant for the post's content
+                content = title
 
-        summary = content[:summary_size]
+            summary = content[:summary_size]
 
-        summary = clean.safe_html(summary)
-        content = clean.safe_html(content)
+            summary = clean.safe_html(summary)
+            content = clean.safe_html(content)
 
-        created = parse_modified_date(entry, resp['feed'])
-        if not created:
-            log.error('Post %s does not has modified date' % link)
-            continue
+            created = parse_modified_date(entry, resp['feed'])
+            if not created:
+                log.error('Post %s does not has modified date' % link)
+                continue
 
-        tags = get_tags(entry)
-        guid = sha.new(link.encode('utf-8')).hexdigest()
+            tags = get_tags(entry)
+            guid = sha.new(link.encode('utf-8')).hexdigest()
 
-        entry = {
-            'title': title,
-            'link': link,
-            'summary': summary,
-            'content': content,
-            'created': created,
-            'guid': guid,
-            'tags': tags,
-        }
-        resp['entries'].append(entry)
+            entry = {
+                'title': title,
+                'link': link,
+                'summary': summary,
+                'content': content,
+                'created': created,
+                'guid': guid,
+                'tags': tags,
+            }
+            resp['entries'].append(entry)
+        except Exception, ex:
+            logging.error(ex)
 
     return resp
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.