handling possible error when parsing cloud category files

This commit is contained in:
Vinicius Moreira
2019-10-17 14:36:14 -03:00
parent 34694a1312
commit 415f6b5ec7
2 changed files with 25 additions and 14 deletions

View File

@@ -2,6 +2,7 @@ import logging
import os
import re
import time
import traceback
from math import ceil
from multiprocessing import Process
from threading import Thread
@@ -152,6 +153,7 @@ class CategoriesDownloader:
res = self.http_client.get(self.URL_CATEGORIES_FILE)
if res:
try:
categories_map = {}
for l in res.text.split('\n'):
if l:
@@ -160,5 +162,9 @@ class CategoriesDownloader:
self.logger.info('Loaded categories for {} AUR packages'.format(len(categories_map)))
return categories_map
except:
self.logger.error("Could not parse AUR categories definitions")
traceback.print_exc()
return {}
else:
self.logger.info('Could not download {}'.format(self.URL_CATEGORIES_FILE))

View File

@@ -88,6 +88,7 @@ class CategoriesDownloader:
res = self.http_client.get(self.URL_CATEGORIES_FILE)
if res:
try:
categories_map = {}
for l in res.text.split('\n'):
if l:
@@ -96,5 +97,9 @@ class CategoriesDownloader:
self.logger.info('Loaded categories for {} Snap applications'.format(len(categories_map)))
return categories_map
except:
self.logger.error("Could not parse categories definitions")
traceback.print_exc()
return {}
else:
self.logger.info('Could not download {}'.format(self.URL_CATEGORIES_FILE))