This commit is contained in:
Kovid Goyal 2018-08-30 07:57:21 +05:30
parent adabb0ee58
commit 03126d37f8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -76,8 +76,14 @@ def connect(path, exc_class=ValueError):
pdir = os.path.dirname(path)
if os.path.isdir(pdir):
raise exc_class('Failed to open userdb database at {} with error: {}'.format(path, as_unicode(e)))
os.makedirs(pdir)
return apsw.Connection(path)
try:
os.makedirs(pdir)
except EnvironmentError as e:
raise exc_class('Failed to make directory for userdb database at {} with error: {}'.format(pdir, as_unicode(e)))
try:
return apsw.Connection(path)
except apsw.CantOpenError as e:
raise exc_class('Failed to open userdb database at {} with error: {}'.format(path, as_unicode(e)))
class UserManager(object):