mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-22 18:39:31 +01:00
ShrinkUrl: Improve error messages when opening the database.
This commit is contained in:
parent
36800ed4bc
commit
ce03729f20
@ -48,12 +48,23 @@ class CdbShrunkenUrlDB(object):
|
|||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
self.dbs = {}
|
self.dbs = {}
|
||||||
cdb = conf.supybot.databases.types.cdb
|
cdb = conf.supybot.databases.types.cdb
|
||||||
def register_service(service):
|
|
||||||
|
services = list(conf.supybot.plugins.ShrinkUrl.default.validStrings)
|
||||||
|
services.append('Expand')
|
||||||
|
for service in services:
|
||||||
dbname = filename.replace('.db', service.capitalize() + '.db')
|
dbname = filename.replace('.db', service.capitalize() + '.db')
|
||||||
self.dbs[service] = cdb.connect(dbname)
|
try:
|
||||||
for service in conf.supybot.plugins.ShrinkUrl.default.validStrings:
|
self.dbs[service] = cdb.connect(dbname)
|
||||||
register_service(service)
|
except OSError as e:
|
||||||
register_service('Expand')
|
log.error(
|
||||||
|
'ShrinkUrl: Can not open database %s: %s',
|
||||||
|
dbname, e)
|
||||||
|
raise KeyError("Could not open %s" % dbname)
|
||||||
|
except:
|
||||||
|
log.exception(
|
||||||
|
'ShrinkUrl: Can not read database %s (data corruption?)',
|
||||||
|
dbname)
|
||||||
|
raise KeyError("Could not open %s" % dbname)
|
||||||
|
|
||||||
def get(self, service, url):
|
def get(self, service, url):
|
||||||
return self.dbs[service][url]
|
return self.dbs[service][url]
|
||||||
|
Loading…
Reference in New Issue
Block a user