File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929from lib .core .defaults import _defaults
3030from lib .core .enums import CONTENT_STATUS
3131from lib .core .enums import PART_RUN_CONTENT_TYPES
32+ from lib .core .exception import SqlmapConnectionException
3233from lib .core .log import LOGGER_HANDLER
3334from lib .core .optiondict import optDict
3435from 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
253257def 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 )
You can’t perform that action at this time.
0 commit comments