(self, key, unserialize=False)
| 86 | return retVal |
| 87 | |
| 88 | def retrieve(self, key, unserialize=False): |
| 89 | retVal = None |
| 90 | |
| 91 | if key and (self._write_cache or self._connections or os.path.isfile(self.filepath)): |
| 92 | hash_ = HashDB.hashKey(key) |
| 93 | retVal = self._write_cache.get(hash_) |
| 94 | if not retVal: |
| 95 | for _ in xrange(HASHDB_RETRIEVE_RETRIES): |
| 96 | try: |
| 97 | for row in self.cursor.execute("SELECT value FROM storage WHERE id=?", (hash_,)): |
| 98 | retVal = row[0] |
| 99 | except (sqlite3.OperationalError, sqlite3.DatabaseError) as ex: |
| 100 | if any(_ in getSafeExString(ex) for _ in ("locked", "no such table")): |
| 101 | warnMsg = "problem occurred while accessing session file '%s' ('%s')" % (self.filepath, getSafeExString(ex)) |
| 102 | singleTimeWarnMessage(warnMsg) |
| 103 | elif "Could not decode" in getSafeExString(ex): |
| 104 | break |
| 105 | else: |
| 106 | errMsg = "error occurred while accessing session file '%s' ('%s'). " % (self.filepath, getSafeExString(ex)) |
| 107 | errMsg += "If the problem persists please rerun with '--flush-session'" |
| 108 | raise SqlmapConnectionException(errMsg) |
| 109 | else: |
| 110 | break |
| 111 | |
| 112 | time.sleep(1) |
| 113 | |
| 114 | if retVal and unserialize: |
| 115 | try: |
| 116 | retVal = unserializeObject(retVal) |
| 117 | except: |
| 118 | retVal = None |
| 119 | warnMsg = "error occurred while unserializing value for session key '%s'. " % key |
| 120 | warnMsg += "If the problem persists please rerun with '--flush-session'" |
| 121 | logger.warning(warnMsg) |
| 122 | |
| 123 | return retVal |
| 124 | |
| 125 | def write(self, key, value, serialize=False): |
| 126 | if key: |
no test coverage detected