Example #1
0
    def __finished(self, success):
        """
        Private slot to handle a finished download.
        
        @param success flag indicating a successful download
        @type bool
        """
        if self.isVisible():
            QApplication.alert(self)

        self.downloadsCountChanged.emit()

        if self.activeDownloadsCount() == 0:
            # all active downloads are done
            if success and e5App().activeWindow() is not self:
                if WebBrowserWindow.notificationsEnabled():
                    WebBrowserWindow.showNotification(
                        UI.PixmapCache.getPixmap("downloads48.png"),
                        self.tr("Downloads finished"),
                        self.tr("All files have been downloaded."))
                if not Preferences.getWebBrowser("DownloadManagerAutoClose"):
                    self.raise_()
                    self.activateWindow()

            self.__stopUpdateTimer()
            self.infoLabel.clear()
            self.setWindowTitle(self.tr("Download Manager"))
            if Globals.isWindowsPlatform():
                self.__taskbarButton().progress().hide()

            if Preferences.getWebBrowser("DownloadManagerAutoClose"):
                self.close()
Example #2
0
 def __finished(self):
     """
     Private slot to handle a finished download.
     """
     self.__updateActiveItemCount()
     if self.isVisible():
         QApplication.alert(self)
Example #3
0
 def __finished(self):
     """
     Private slot to handle a finished download.
     """
     self.__updateActiveItemCount()
     if self.isVisible():
         QApplication.alert(self)
Example #4
0
    def on_finished() -> None:
        on_extract_data_finished()

        play_finish_notification()

        QApplication.alert(main_window)

        update_station_id_push_buttons()
Example #5
0
    def on_error(message: str) -> None:
        on_extract_data_finished()

        on_status_changed("Crashed!")

        play_error_notification()

        QApplication.alert(main_window)

        QMessageBox.warning(main_window, 'Warning', message, QMessageBox.Ok)
Example #6
0
    def statusChanged(self, status):
        self.handleCursor(status)

        if status == QMediaPlayer.LoadingMedia:
            self.setStatusInfo("Loading...")
        elif status == QMediaPlayer.StalledMedia:
            self.setStatusInfo("Media Stalled")
        elif status == QMediaPlayer.EndOfMedia:
            QApplication.alert(self)
        elif status == QMediaPlayer.InvalidMedia:
            self.displayErrorMessage()
        else:
            self.setStatusInfo("")
Example #7
0
    def statusChanged(self, status):
        self.handleCursor(status)

        if status == QMediaPlayer.LoadingMedia:
            self.setStatusInfo("Loading...")
        elif status == QMediaPlayer.StalledMedia:
            self.setStatusInfo("Media Stalled")
        elif status == QMediaPlayer.EndOfMedia:
            QApplication.alert(self)
        elif status == QMediaPlayer.InvalidMedia:
            self.displayErrorMessage()
        else:
            self.setStatusInfo("")
Example #8
0
    def processPendingDatagrams(self):
        """
        处理数据
        """
        while self.udpSocket.hasPendingDatagrams():
            data, host, port = self.udpSocket.readDatagram(
                self.udpSocket.pendingDatagramSize())

            datagram = str(data, encoding='utf-8')

            datagramDict = json.loads(datagram)

            messageType = datagramDict["messageType"]
            userName = datagramDict["userName"]
            localHostName = datagramDict["localHostName"]
            ipAddress = datagramDict["ipAddress"]

            time = QDateTime.currentDateTime().toString("yyyy-MM-dd hh:mm:ss")

            if messageType == Chat.Message:
                message = datagramDict["message"]
                isAtUsername = self.findAt(message)
                if isAtUsername == self.getUserName():
                    QApplication.alert(self, 0)
                    # 非弹窗告警
                self.messageBrowser.setTextColor(Qt.blue)
                self.messageBrowser.setCurrentFont(QFont(
                    "Times New Roman", 12))
                self.messageBrowser.append("[" + userName + "]" + time)
                self.messageBrowser.append(message)

            elif messageType == Chat.NewParticipant:
                self.newParticipant(userName, localHostName, ipAddress)

            elif messageType == Chat.ParticipantLeft:
                self.participantLeft(userName, ipAddress, time)

            elif messageType == Chat.FileName:
                clientAddress = datagramDict["clientAddress"]
                fileName = datagramDict["sendFileName"]
                self.hasPendingFile(userName, ipAddress, clientAddress,
                                    fileName)
                # 收到的信息类型是Chat.FileName时,我们取得客户端地址和文件名。同时调用hasPendingFile()处理文件。

            elif messageType == Chat.Refuse:
                serverip = ipAddress
                ipAddress = self.getIP()
                if ipAddress == serverip:
                    self.server.refused()
Example #9
0
    def statusChanged(self, status):
        self.handleCursor(status)

        if status == QMediaPlayer.LoadingMedia:
            self.setStatusInfo("Loading")
        elif status == QMediaPlayer.LoadedMedia:
            self.setStatusInfo("Loaded")
            self.mediaPlayer.play()
        elif status == QMediaPlayer.BufferingMedia:
            self.setStatusInfo("Buffering")
        elif status == QMediaPlayer.EndOfMedia:
            QApplication.alert(self)
        elif status == (QMediaPlayer.InvalidMedia or QMediaPlayer.NoMedia):
            self.displayError()
        else:
            self.setStatusInfo("")
Example #10
0
 def status_changed(self, status):
     if QMediaPlayer.UnknownMediaStatus == status \
             or QMediaPlayer.NoMedia == status \
             or QMediaPlayer.LoadedMedia == status \
             or QMediaPlayer.BufferedMedia == status:
         self.set_status_info("")
     elif QMediaPlayer.LoadingMedia == status:
         self.set_status_info("加载中...")
     elif QMediaPlayer.BufferingMedia == status:
         self.set_status_info("缓存中...")
     elif QMediaPlayer.StalledMedia == status:
         self.set_status_info("等待中...")
     elif QMediaPlayer.EndOfMedia == status:
         QApplication.alert(self)
     elif QMediaPlayer.InvalidMedia == status:
         self.display_error_message()
Example #11
0
    def showWindow(self, event):
        """ Show child windows.
        If event is QSystemTrayIcon.Trigger then it checks if
        all windows are not open and show addWindow.

        If event is 'addAction' it means that user from editWindow
        want to edit reminder, so it opens addWindow.

        Then it checks if addAction or editAction is True, and alert
        appropriate window.

        Then if event is 'editAction' then it opens editWindow.

        """
        if event == 'editAction':
            if self.editActive:
                QApplication.alert(self.editWindow)
            else:
                self.editWindow = EditWindow(self)
                self.editWindow.show()
                self.editWindow.setFocus(True)
                self.editWindow.activateWindow()
            return self.editWindow
        elif event == 'addAction':
            self.addWindow = AddWindow(self)
            self.addWindow.show()
            self.addWindow.setFocus(True)
            self.addWindow.activateWindow()
            return self.addWindow
        elif event == QSystemTrayIcon.Trigger:
            if self.addActive:
                QApplication.alert(self.addWindow)
            else:
                self.addWindow = AddWindow(self)
                self.addWindow.show()
                self.addWindow.setFocus(True)
                self.addWindow.activateWindow()
            return self.addWindow
        elif event == 'optAction':
            if self.addActive:
                self.addWindow.hide()
            if self.editActive:
                self.editWindow.hide()
            self.optWindow = OptionsWindow(self)
            self.optWindow.show()
            self.optWindow.setFocus(True)
            self.optWindow.activateWindow()
Example #12
0
    def on_finished(
        loaded_data: dict, loaded_anomaly_data: dict, loaded_is_trained: bool,
        loaded_trained_on: (bool, bool, bool)) -> None:
        nonlocal data, anomaly_data, is_trained, trained_on, \
            min_temperature_combo_box, max_temperature_combo_box, average_temperature_combo_box
        data = loaded_data
        anomaly_data = loaded_anomaly_data
        is_trained = loaded_is_trained
        trained_on = loaded_trained_on

        play_finish_notification()

        on_load_finished()

        QApplication.alert(main_window)

        select_period_type_combo_box.setCurrentIndex(0)

        station_id = get_station_id()

        reset_observation(select_diagram_observation_vertical_layout)
        min_temperature_combo_box, max_temperature_combo_box, average_temperature_combo_box = \
            set_observation(
                select_diagram_observation_vertical_layout,
                lambda state: update_diagram_override(),
                stations_info[station_id]["need_min"],
                stations_info[station_id]["need_max"],
                stations_info[station_id]["need_average"])

        reset_anomaly_observation(station_id,
                                  select_observation_for_anomaly_combo_box)
        if is_custom_data_window_open:
            # noinspection PyTypeChecker
            reset_anomaly_observation(
                station_id, custom_data_observation_for_anomaly_combo_box)
            if stations_info[station_id]["is_trained"]:
                # noinspection PyUnresolvedReferences
                custom_data_window.setEnabled(True)
                # noinspection PyStatementEffect,PyUnresolvedReferences
                custom_data_window.setToolTip(None)
            else:
                # noinspection PyUnresolvedReferences
                custom_data_window.setEnabled(False)
                # noinspection PyStatementEffect,PyUnresolvedReferences
                custom_data_window.setToolTip(
                    "Data isn't trained for this station")
Example #13
0
    def on_finished(need_min: bool, need_max: bool, need_average: bool) -> None:
        on_train_finished()

        play_finish_notification()

        QApplication.alert(main_window)

        train_push_button.setText("Retrain")

        station_id = get_station_id()
        stations_info[station_id]["is_trained"] = True
        stations_info[station_id]["is_min_trained"] = need_min
        stations_info[station_id]["is_max_trained"] = need_max
        stations_info[station_id]["is_average_trained"] = need_average
        stations_info[station_id]["is_cashed_anomaly_data"] = False

        write_stations_info_to_json(stations_info)
Example #14
0
    def processPendingDatagrams(self):
        """
        处理收到的消息
        """

        while self.udpSocket.hasPendingDatagrams():
            # 开启循环,让udpSocket等待接收数据

            data, host, port = self.udpSocket.readDatagram(
                self.udpSocket.pendingDatagramSize())
            # 读取收到的UDP数据,大小是返回第一个挂起的UDP数据报的大小。返回值是数据、主机信息、端口信息。

            datagram = str(data, encoding='utf-8')

            datagramDict = json.loads(datagram)  # 转换成字典

            messageType = datagramDict["messageType"]
            userName = datagramDict["userName"]
            localHostName = datagramDict["localHostName"]
            ipAddress = datagramDict["ipAddress"]
            # 字节流信息转成字符串并变成字典,取得消息类型、用户名、主机名和IP地址。

            time = QDateTime.currentDateTime().toString("yyyy-MM-dd hh:mm:ss")

            if messageType == Chat.Message:

                message = datagramDict["message"]
                isAtUsername = self.findAt(message)
                if isAtUsername == self.getUserName():
                    QApplication.alert(self, 0)
                    # 如果窗口不是活动窗口,则会为窗口小部件显示警报。

                self.messageBrowser.setTextColor(Qt.blue)
                self.messageBrowser.setCurrentFont(QFont(
                    "Times New Roman", 12))
                self.messageBrowser.append("[" + userName + "]" + time)
                self.messageBrowser.append(message)
                # 在消息展示区增加相应的发送人和聊天内容

            elif messageType == Chat.NewParticipant:
                self.newParticipant(userName, localHostName, ipAddress)

            elif messageType == Chat.ParticipantLeft:
                self.participantLeft(userName, ipAddress, time)
Example #15
0
    def status_changed(self, status):
        """

        :param status:
        :return:
        """

        self.handle_cursor(status)

        if status == QMediaPlayer.LoadingMedia:
            self.set_status_info("Loading...")

        elif status == QMediaPlayer.StalledMedia:
            self.set_status_info("Media Stalled")

        elif status == QMediaPlayer.EndOfMedia:
            QApplication.alert(self)

        elif status == QMediaPlayer.InvalidMedia:
            self.display_error_message()

        else:
            self.set_status_info("")
Example #16
0
 def open_message_box(self):
     global sort_task_list
     # alert은 밑에 알림창을 울리게 함 그리고 이 메시지 박스는 내가 보고 있는 화면에 띄워짐
     QApplication.alert(QMessageBox.about(self, 'Message', '{time}\n{task}'.format( \
                                         time=list(sort_task_list[0].keys())[0],
                                         task=list(sort_task_list[0].values())[0])))
Example #17
0
    def print_results(self):
        try:
            while True:
                result = self.q.get_nowait()

                whitelisted_ids = []
                whitelist_file = get_setting("whitelist_file_location")
                # whitelist_file is the empty strign if no file has been specified
                if whitelist_file:
                    whitelist_file = Path(whitelist_file)

                    with open(whitelist_file) as f:
                        lines = f.readlines()
                        for line in lines:
                            # remove comment if there is one
                            line = line.rsplit("#")[0]
                            # allow whitespace on either end of the id
                            line = line.strip()
                            # allow empty lines anywhere in the file
                            if line == "":
                                continue
                            # TODO: nicer error if the line is an invalid id?
                            try:
                                line = int(line)
                            except ValueError:
                                self.write_to_terminal_signal.emit("<div style='color:#ff5252'>Invalid "
                                    f"user id in whitelist file:</div> \"{line}\" is not a valid user id.")
                                continue
                            whitelisted_ids.append(line)

                ts = datetime.now() # ts = timestamp
                message = None
                ischeat = False
                if isinstance(result, StealResult):
                    if result.earlier_replay.user_id in whitelisted_ids:
                        pass
                    elif result.similarity < get_setting("steal_max_sim"):
                        ischeat = True
                        message = get_setting("message_steal_found").format(ts=ts, sim=result.similarity, r=result, replay1=result.replay1, replay2=result.replay2,
                                        earlier_replay_mods_short_name=result.earlier_replay.mods.short_name(), earlier_replay_mods_long_name=result.earlier_replay.mods.long_name(),
                                        later_replay_mods_short_name=result.later_replay.mods.short_name(), later_replay_mods_long_name=result.later_replay.mods.long_name())
                    elif result.similarity < get_setting("steal_max_sim_display"):
                        message = get_setting("message_steal_found_display").format(ts=ts, sim=result.similarity, r=result, replay1=result.replay1,
                                        earlier_replay_mods_short_name=result.earlier_replay.mods.short_name(), earlier_replay_mods_long_name=result.earlier_replay.mods.long_name(),
                                        later_replay_mods_short_name=result.later_replay.mods.short_name(), later_replay_mods_long_name=result.later_replay.mods.long_name())

                if isinstance(result, RelaxResult):
                    if result.replay.user_id in whitelisted_ids:
                        pass
                    elif result.ur < get_setting("relax_max_ur"):
                        ischeat = True
                        message = get_setting("message_relax_found").format(ts=ts, r=result, replay=result.replay, ur=result.ur,
                                                mods_short_name=result.replay.mods.short_name(), mods_long_name=result.replay.mods.long_name())
                    elif result.ur < get_setting("relax_max_ur_display"):
                        message = get_setting("message_relax_found_display").format(ts=ts, r=result, replay=result.replay, ur=result.ur,
                                                mods_short_name=result.replay.mods.short_name(), mods_long_name=result.replay.mods.long_name())

                if isinstance(result, CorrectionResult):
                    if result.replay.user_id in whitelisted_ids:
                        pass
                    elif len(result.snaps) > 0:
                        ischeat = True
                        snap_message = get_setting("message_correction_snaps")
                        snap_text = "\n".join([snap_message.format(time=snap.time, angle=snap.angle, distance=snap.distance) for snap in result.snaps])
                        message = get_setting("message_correction_found").format(ts=ts, r=result, replay=result.replay, snaps=snap_text,
                                                mods_short_name=result.replay.mods.short_name(), mods_long_name=result.replay.mods.long_name())

                if isinstance(result, TimewarpResult):
                    if result.replay.user_id in whitelisted_ids:
                        pass
                    elif result.frametime < get_setting("timewarp_max_frametime"):
                        ischeat = True
                        message = get_setting("message_timewarp_found").format(ts=ts, r=result, replay=result.replay, frametime=result.frametime,
                                                mods_short_name=result.replay.mods.short_name(), mods_long_name=result.replay.mods.long_name())
                    elif result.frametime < get_setting("timewarp_max_frametime_display"):
                        message = get_setting("message_timewarp_found_display").format(ts=ts, r=result, replay=result.replay, frametime=result.frametime,
                                                mods_short_name=result.replay.mods.short_name(), mods_long_name=result.replay.mods.long_name())

                if message or isinstance(result, AnalysisResult):
                    self.show_no_cheat_found = False
                if message:
                    self.write(message)
                if isinstance(result, AnalysisResult):
                    self.add_result_signal.emit(result)
                else:
                    if ischeat:
                        QApplication.beep()
                        QApplication.alert(self)
                        # add to Results Tab so it can be played back on demand
                        self.add_result_signal.emit(result)

        except Empty:
            try:
                result = self.url_analysis_q.get_nowait()
                self.add_url_analysis_result_signal.emit(result)
            except Empty:
                pass
        self.print_results_event.set()