Sat, 26 Apr 2025 12:34:32 +0200
MicroPython
- Added a configuration option to disable the support for the no longer produced Pimoroni Pico Wireless Pack.
11206
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
3 | # Copyright (c) 2025 Detlev Offenbach <detlev@die-offenbachs.de> |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog to show a list of existing crash session files. |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
11207
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
10 | import contextlib |
11206
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | import json |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | import os |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | import time |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | from PyQt6.QtCore import Qt, pyqtSlot |
11207
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
16 | from PyQt6.QtWidgets import ( |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
17 | QAbstractItemView, |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
18 | QDialog, |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
19 | QDialogButtonBox, |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
20 | QListWidgetItem, |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
21 | ) |
11206
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | from eric7.EricWidgets import EricMessageBox |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | from .Ui_CrashedSessionsSelectionDialog import Ui_CrashedSessionsSelectionDialog |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | class CrashedSessionsSelectionDialog(QDialog, Ui_CrashedSessionsSelectionDialog): |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | """ |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | Class implementing a dialog to show a list of existing crash session files. |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | """ |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | |
11207
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
33 | def __init__(self, sessionFiles, deleteMode=False, parent=None): |
11206
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | """ |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | Constructor |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | @param sessionFiles list of crash session file names |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | @type list of str |
11207
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
39 | @param deleteMode flag indicating the delete mode (defaults to False) |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
40 | @type bool (optional) |
11206
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | @param parent reference to the parent widget (defaults to None) |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | @type QWidget (optional) |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | """ |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | super().__init__(parent) |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | self.setupUi(self) |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | self.crashedSessionsList.itemDoubleClicked.connect(self.accept) |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | self.crashedSessionsList.itemActivated.connect(self.accept) |
11207
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
49 | self.crashedSessionsList.itemSelectionChanged.connect(self.__updateButtonStates) |
11206
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | for sessionFile in sessionFiles: |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | self.__addSessionFileEntry(sessionFile) |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | |
11207
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
54 | self.__deleteMode = deleteMode |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
55 | if deleteMode: |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
56 | self.setWindowTitle(self.tr("Clean Crash Sessions")) |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
57 | self.messageLabel.setText( |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
58 | self.tr( |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
59 | "These crash session files were found. Select the ones to be" |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
60 | " deleted." |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
61 | ) |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
62 | ) |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
63 | self.crashedSessionsList.setSelectionMode( |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
64 | QAbstractItemView.SelectionMode.ExtendedSelection |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
65 | ) |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
66 | self.removeButton.hide() |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
67 | else: |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
68 | self.setWindowTitle(self.tr("Found Crash Sessions")) |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
69 | self.messageLabel.setText( |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
70 | self.tr( |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
71 | "These crash session files were found. Select the one to open." |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
72 | " Select 'Cancel' to not open a crash session." |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
73 | ) |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
74 | ) |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
75 | |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
76 | self.__updateButtonStates() |
11206
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | @pyqtSlot() |
11207
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
79 | def __updateButtonStates(self): |
11206
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | """ |
11207
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
81 | Private method to update the enabled state of the buttons. |
11206
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | """ |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | bool(self.crashedSessionsList.selectedItems()) |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | ) |
11207
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
86 | self.removeButton.setEnabled(bool(self.crashedSessionsList.selectedItems())) |
11206
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | def __addSessionFileEntry(self, sessionFile): |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | """ |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | Private method to read the given session file and add a list entry for it. |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | @param sessionFile file name of the session to be read |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | @type str |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | """ |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | if os.path.exists(sessionFile): |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | try: |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | with open(sessionFile, "r") as f: |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | jsonString = f.read() |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | sessionDict = json.loads(jsonString) |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | except (OSError, json.JSONDecodeError) as err: |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | EricMessageBox.critical( |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | None, |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | self.tr("Read Crash Session"), |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | self.tr( |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | "<p>The crash session file <b>{0}</b> could not be read.</p>" |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | "<p>Reason: {1}</p>" |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | ).format(sessionFile, str(err)), |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | ) |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | mtime = os.path.getmtime(sessionFile) |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(mtime)) |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | if sessionDict["Project"]: |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | labelText = self.tr( |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | "{0}\nTimestamp: {1}\nProject: {2}", |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | "Crash Session, Timestamp, Project Path", |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | ).format(sessionFile, timestamp, sessionDict["Project"]) |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | else: |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | labelText = self.tr( |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | "{0}\nTimestamp: {1}", "Crash Session, Timestamp" |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | ).format(sessionFile, timestamp) |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | itm = QListWidgetItem(labelText, self.crashedSessionsList) |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | itm.setData(Qt.ItemDataRole.UserRole, sessionFile) |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | |
11207
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
124 | @pyqtSlot() |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
125 | def on_removeButton_clicked(self): |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
126 | """ |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
127 | Private slot to remove the selected crash session files. |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
128 | """ |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
129 | for itm in self.crashedSessionsList.selectedItems(): |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
130 | crashSession = itm.data(Qt.ItemDataRole.UserRole) |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
131 | with contextlib.suppress(OSError): |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
132 | os.remove(crashSession) |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
133 | self.crashedSessionsList.takeItem(self.crashedSessionsList.row(itm)) |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
134 | del itm |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
135 | |
11206
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | def getSelectedCrashSession(self): |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | """ |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | Public method to get the selected crash session file name. |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | @return file name of the selected crash session |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | @rtype str |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | """ |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | selectedItems = self.crashedSessionsList.selectedItems() |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | if selectedItems: |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | return selectedItems[0].data(Qt.ItemDataRole.UserRole) |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | else: |
9271719f43a7
Modified the display of the crash session dialog to show the time stamp of the found crash session file and the path of the project file (if a project was open) (see issue584).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | return None |
11207
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
149 | |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
150 | def getSelectedCrashSessions(self): |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
151 | """ |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
152 | Public method to get the selected crash session file names. |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
153 | |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
154 | @return file names of the selected crash sessions |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
155 | @rtype list of str |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
156 | """ |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
157 | selectedItems = self.crashedSessionsList.selectedItems() |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
158 | |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
159 | if selectedItems: |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
160 | return [itm.data(Qt.ItemDataRole.UserRole) for itm in selectedItems] |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
161 | else: |
7193db06924d
Modified the display of the crash session dialog to allow the removal of crash session files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11206
diff
changeset
|
162 | return [] |