Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9bd41ed

Browse files
committed
Fixes #1189
1 parent 02fb505 commit 9bd41ed

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

lib/utils/api.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from lib.core.defaults import _defaults
3030
from lib.core.enums import CONTENT_STATUS
3131
from lib.core.enums import PART_RUN_CONTENT_TYPES
32+
from lib.core.exception import SqlmapConnectionException
3233
from lib.core.log import LOGGER_HANDLER
3334
from lib.core.optiondict import optDict
3435
from lib.core.subprocessng import Popen
@@ -66,8 +67,11 @@ def connect(self, who="server"):
6667
logger.debug("REST-JSON API %s connected to IPC database" % who)
6768

6869
def disconnect(self):
69-
self.cursor.close()
70-
self.connection.close()
70+
if self.cursor:
71+
self.cursor.close()
72+
73+
if self.connection:
74+
self.connection.close()
7175

7276
def commit(self):
7377
self.connection.commit()
@@ -252,8 +256,11 @@ def emit(self, record):
252256

253257
def setRestAPILog():
254258
if hasattr(conf, "api"):
255-
conf.database_cursor = Database(conf.database)
256-
conf.database_cursor.connect("client")
259+
try:
260+
conf.database_cursor = Database(conf.database)
261+
conf.database_cursor.connect("client")
262+
except sqlite3.OperationalError, ex:
263+
raise SqlmapConnectionException, "%s ('%s')" % (ex, conf.database)
257264

258265
# Set a logging handler that writes log messages to a IPC database
259266
logger.removeHandler(LOGGER_HANDLER)

0 commit comments

Comments
 (0)