예제 #1
0
파일: request.py 프로젝트: Webiny/projects
    def createFromNodeJs(self, data):
        if not self._validateNodeJsData(data):
            return False

        self._populateFromNodeJs(data)
        Debugger.log("Storing request data to Database...", 'debug')
        db = Database()

        # Storing main table
        query = "INSERT INTO requests (id, datetime, url, memory, stats, get, post, server, level, read)" \
                " VALUES (NULL, ?,?,?,?,?,?,?,?,0)"
        bind = (self._datetime, self._url, self._memory, JSON.encode(self._stats), JSON.encode(self._get),
                JSON.encode(self._post), JSON.encode(self._server), self._level)
        db.execute(query, bind)
        self._id = db.last_inserted_id

        # Storing messages
        messages = self._messages
        self._messages = []
        for message in messages:
            m = Message()
            message['request'] = self._id
            m.createFromNodeJs(message)
            self._messages.append(m)

        """
        Modify data (this will also affect the Request table model)
        """
        settings = Settings()
        if Request._RECORDS is not None:
            Request._RECORDS.insert(0, self)
            if len(Request._RECORDS) > settings.requests_limit:
                del Request._RECORDS[-1]

        return True
예제 #2
0
파일: request.py 프로젝트: Webiny/projects
 def _validateNodeJsData(self, data):
     valid = True
     keys = ['memory', 'url', 'datetime', 'messages', 'stats', 'get', 'post', 'server', 'level']
     for key in keys:
         if key not in data:
             Debugger.log("Key '" + key + "' is missing in Request data!", 'error')
             valid = False
     return valid
예제 #3
0
파일: message.py 프로젝트: Webiny/projects
 def _validateNodeJsData(self, data):
     valid = True
     keys = ['name', 'message', 'datetime', 'level', 'context', 'extra', 'request', 'line', 'file']
     for key in keys:
         if key not in data:
             Debugger.log("Key '" + key + "' is missing in Message data!", 'error')
             valid = False
     return valid
예제 #4
0
 def iconClicked(self, reason):
     if reason == 2:
         Debugger.log('Tray icon clicked')
         if not hasattr(self, "mainWindow"):
             self.mainWindow = MainWindow(self)
             self.mainWindow.activateWindow()
         if self.mainWindow.isVisible():
             self.mainWindow.hide()
         else:
             self.mainWindow.show()
             self.mainWindow.activateWindow()
예제 #5
0
    def newNotification(self, params):
        # Store new request
        request = Request()
        request.createFromNodeJs(params)

        # Notification balloon
        if bool(self.settings.show_balloon) and bool(self.settings.log_levels[request.getLevel()]['balloon']):
            message = "[" + strftime("%Y-%m-%d %H:%M:%S", gmtime()) + "] New notification received!"
            Debugger.log('Showing tray message: ' + message)
            self.tray.showMessage('Webiny Notifier', message, QtGui.QSystemTrayIcon.Information, 10000000)
        self.refreshRequestsModel()
예제 #6
0
    def balloonClicked(self):
        Debugger.log('Balloon clicked')
        if not hasattr(self, "mainWindow"):
            self.mainWindow = MainWindow(self)
        if not self.mainWindow.isVisible():
            self.mainWindow.show()

        if self.mainWindow.isMinimized():
            self.mainWindow.showNormal()

        self.mainWindow.activateWindow()
        self.mainWindow.selectFirstRow()
예제 #7
0
파일: message.py 프로젝트: Webiny/projects
    def createFromNodeJs(self, data):
        if not self._validateNodeJsData(data):
            return False

        self._populateFromNodeJs(data)
        Debugger.log("Storing message data to Database...", 'debug')
        db = Database()

        # Storing main table
        query = "INSERT INTO messages (`group`, message, file, line, memory, level, datetime, context, extra, request) " \
                "VALUES (?,?,?,?,?,?,?,?,?,?)"
        bind = (
            self._group, self._message, self._file, self._line, self._memory, self._level, self._datetime, JSON.encode(self._context),
            JSON.encode(self._extra), self._request)
        db.execute(query, bind)
        self._id = db.last_inserted_id
        return True