mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 08:34:17 +02:00
handling possible error when parsing cloud category files
This commit is contained in:
@@ -2,6 +2,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
import traceback
|
||||||
from math import ceil
|
from math import ceil
|
||||||
from multiprocessing import Process
|
from multiprocessing import Process
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
@@ -152,13 +153,18 @@ class CategoriesDownloader:
|
|||||||
res = self.http_client.get(self.URL_CATEGORIES_FILE)
|
res = self.http_client.get(self.URL_CATEGORIES_FILE)
|
||||||
|
|
||||||
if res:
|
if res:
|
||||||
categories_map = {}
|
try:
|
||||||
for l in res.text.split('\n'):
|
categories_map = {}
|
||||||
if l:
|
for l in res.text.split('\n'):
|
||||||
data = l.split('=')
|
if l:
|
||||||
categories_map[data[0]] = [c.strip() for c in data[1].split(',') if c]
|
data = l.split('=')
|
||||||
|
categories_map[data[0]] = [c.strip() for c in data[1].split(',') if c]
|
||||||
|
|
||||||
self.logger.info('Loaded categories for {} AUR packages'.format(len(categories_map)))
|
self.logger.info('Loaded categories for {} AUR packages'.format(len(categories_map)))
|
||||||
return categories_map
|
return categories_map
|
||||||
|
except:
|
||||||
|
self.logger.error("Could not parse AUR categories definitions")
|
||||||
|
traceback.print_exc()
|
||||||
|
return {}
|
||||||
else:
|
else:
|
||||||
self.logger.info('Could not download {}'.format(self.URL_CATEGORIES_FILE))
|
self.logger.info('Could not download {}'.format(self.URL_CATEGORIES_FILE))
|
||||||
|
|||||||
@@ -88,13 +88,18 @@ class CategoriesDownloader:
|
|||||||
res = self.http_client.get(self.URL_CATEGORIES_FILE)
|
res = self.http_client.get(self.URL_CATEGORIES_FILE)
|
||||||
|
|
||||||
if res:
|
if res:
|
||||||
categories_map = {}
|
try:
|
||||||
for l in res.text.split('\n'):
|
categories_map = {}
|
||||||
if l:
|
for l in res.text.split('\n'):
|
||||||
data = l.split('=')
|
if l:
|
||||||
categories_map[data[0]] = [c.strip() for c in data[1].split(',') if c]
|
data = l.split('=')
|
||||||
|
categories_map[data[0]] = [c.strip() for c in data[1].split(',') if c]
|
||||||
|
|
||||||
self.logger.info('Loaded categories for {} Snap applications'.format(len(categories_map)))
|
self.logger.info('Loaded categories for {} Snap applications'.format(len(categories_map)))
|
||||||
return categories_map
|
return categories_map
|
||||||
|
except:
|
||||||
|
self.logger.error("Could not parse categories definitions")
|
||||||
|
traceback.print_exc()
|
||||||
|
return {}
|
||||||
else:
|
else:
|
||||||
self.logger.info('Could not download {}'.format(self.URL_CATEGORIES_FILE))
|
self.logger.info('Could not download {}'.format(self.URL_CATEGORIES_FILE))
|
||||||
|
|||||||
Reference in New Issue
Block a user