-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdbus_monitor.py
230 lines (180 loc) · 16.9 KB
/
dbus_monitor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
from log import MeticulousLogger
from notifications import NotificationManager, Notification, NotificationResponse
import subprocess
from dbus_client import AsyncDBUSClient
from api.machine import OSStatus, UpdateOSStatus
notification = None
notification_image = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QCMRXhpZgAATU0AKgAAAAgABQEGAAMAAAABAAIAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAABIAAAAAQAAAEgAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAAHigAwAEAAAAAQAAAHgAAAAA/+EKHmh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8APD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczpJcHRjNHhtcEV4dD0iaHR0cDovL2lwdGMub3JnL3N0ZC9JcHRjNHhtcEV4dC8yMDA4LTAyLTI5LyIgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIiBJcHRjNHhtcEV4dDpBcnR3b3JrVGl0bGU9IklNR18wMTUzIj4gPGRjOnRpdGxlPiA8cmRmOkFsdD4gPHJkZjpsaSB4bWw6bGFuZz0ieC1kZWZhdWx0Ij5JTUdfMDE1MzwvcmRmOmxpPiA8L3JkZjpBbHQ+IDwvZGM6dGl0bGU+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDw/eHBhY2tldCBlbmQ9InciPz4A/+0AVFBob3Rvc2hvcCAzLjAAOEJJTQQEAAAAAAAcHAFaAAMbJUccAgAAAgACHAIFAAhJTUdfMDE1MzhCSU0EJQAAAAAAEBjhobF5EfORRA4uKezMGfP/wAARCAB4AHgDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEK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K4AZiBwBgAADoAM5OSe2orgzLiXHYymqWIqXjvayX5JH0HDXhpkeUV3icuwyhNq1+aUtPLmk7fIKXJpKK8I+6P/1vH6XaT0FB61Yj+6K/kZs/1vbK+0+lG0jtU/8X+fWlk6fhS5hXKwFLtNKvWnUNlqKIxu7Uoz3py9aae340wtYM54NGRSUUWEKaSiimAUUUUALjjNN3t/dqZfufif5VFUNks//9k="
progress_notification: Notification | None = Notification("")
progress_notification.image = notification_image
error_rauc_updating = ""
logger = MeticulousLogger.getLogger(__name__)
class DBusMonitor:
dbus_object = AsyncDBUSClient()
@classmethod
def init(self):
self.dbus_object.new_signal_subscription(
"com.Meticulous.Handler.Updater",
"UpdateFailed",
self.recovery_update_failed,
)
self.dbus_object.new_signal_subscription(
"de.pengutronix.rauc.Installer", "Completed", self.rauc_update_complete
)
self.dbus_object.new_signal_subscription(
"com.Meticulous.Handler.MassStorage", "NewUSB", self.notify_usb
)
# signal to identify the OS update is from the USB
self.dbus_object.new_signal_subscription(
"com.Meticulous.Handler.MassStorage", "RecoveryUpdate", self.recovery_update
)
self.dbus_object.new_signal_subscription(
"org.hawkbit.DownloadProgress",
"ProgressUpdate",
self.download_progress,
)
self.dbus_object.new_property_subscription(
"de.pengutronix.rauc.Installer", "Progress", self.install_progress
)
self.dbus_object.new_property_subscription(
"de.pengutronix.rauc.Installer", "LastError", self.report_error
)
self.dbus_object.start()
@staticmethod
async def download_progress(
connection,
sender_name,
object_path,
interface_name,
signal_name,
parameters: tuple,
):
percentage = parameters[0]
UpdateOSStatus.sendStatus(OSStatus.DOWNLOADING, round(percentage), None)
if UpdateOSStatus.isRecoveryUpdate():
progress_notification.message = f"Downloading update: {percentage}%"
progress_notification.respone_options = [NotificationResponse.OK]
progress_notification.image = notification_image
NotificationManager.add_notification(progress_notification)
@staticmethod
async def install_progress(
connection,
sender_name,
object_path,
property_interface,
attribute,
status: tuple[int, str, int],
):
(progress, message, depth) = status
progress_notification.message = f"Updating OS:\n {progress}%"
progress_notification.respone_options = [NotificationResponse.OK]
progress_notification.image = notification_image
UpdateOSStatus.sendStatus(OSStatus.INSTALLING, progress, None)
if UpdateOSStatus.isRecoveryUpdate():
NotificationManager.add_notification(progress_notification)
@staticmethod
async def report_error(
connection, sender_name, object_path, property_interface, attribute, status
):
global error_rauc_updating
error_rauc_updating = status
if status == "":
return
notification_message = f"There was an error updating the OS:\n {status}"
UpdateOSStatus.sendStatus(OSStatus.FAILED, 0, status)
if UpdateOSStatus.isRecoveryUpdate():
# dismiss progress notification
progress_notification.image = ""
progress_notification.message = ""
NotificationManager.add_notification(progress_notification)
NotificationManager.add_notification(
Notification(
message=notification_message,
responses=[NotificationResponse.OK],
image=notification_image,
)
)
UpdateOSStatus.markAsRecoveryUpdate(False)
subprocess_result = subprocess.run(
"umount /tmp/possible_updater", shell=True, capture_output=True
)
logger.warning(f"{subprocess_result}")
subprocess_result = subprocess.run(
"rm -r /tmp/possible_updater", shell=True, capture_output=True
)
logger.warning(f"{subprocess_result}")
@staticmethod
async def rauc_update_complete(
connection, sender_name, object_path, interface_name, signal_name, parameters
):
UpdateOSStatus.sendStatus(OSStatus.COMPLETE, 100, None)
if error_rauc_updating != "":
notification_message = f"Failed OS updated no need to reboot your machine\n Error: {error_rauc_updating}"
logger.info(f"error is [{error_rauc_updating}]")
else:
notification_message = "OS updated. Remove USB and reboot your machine"
# dismiss progress notification
if UpdateOSStatus.isRecoveryUpdate():
progress_notification.image = ""
progress_notification.message = ""
NotificationManager.add_notification(progress_notification)
NotificationManager.add_notification(
Notification(
message=notification_message,
responses=[NotificationResponse.OK],
image=notification_image,
)
)
UpdateOSStatus.markAsRecoveryUpdate(False)
subprocess_result = subprocess.run(
"umount /tmp/possible_updater", shell=True, capture_output=True
)
logger.warning(f"{subprocess_result}")
subprocess_result = subprocess.run(
"rm -r /tmp/possible_updater", shell=True, capture_output=True
)
logger.warning(f"{subprocess_result}")
@staticmethod
async def just_print(
self,
connection,
sender_name,
object_path,
property_interface,
attribute,
status,
):
logger.info(f"property: [{attribute}], is [{status}]")
@staticmethod
async def notify_usb(
connection, sender_name, object_path, interface_name, signal_name, parameters
):
logger.info(f"received signal NEW USB with parameters: [{parameters}]")
USB_PATH = parameters[0]
logger.info(f"USB PATH RECEIVED: {USB_PATH}")
@staticmethod
async def recovery_update_failed(
connection, sender_name, object_path, interface_name, signal_name, parameters
):
error_message: str = (
f"Recovery Update Failed:\n {parameters[0] if parameters[0] != 'unknown' else 'unknown error, possible USB disconnection'}"
)
progress_notification.image = ""
progress_notification.message = ""
UpdateOSStatus.sendStatus(OSStatus.FAILED, 0, parameters[0])
NotificationManager.add_notification(progress_notification)
NotificationManager.add_notification(
Notification(
message=error_message,
responses=[NotificationResponse.OK],
image=notification_image,
)
)
UpdateOSStatus.markAsRecoveryUpdate(False)
logger.info(f"RECOVERY UPDATE FAILED: {error_message}")
@staticmethod
async def recovery_update(
connection, sender_name, object_path, interface_name, signal_name, parameters
):
UpdateOSStatus.markAsRecoveryUpdate(True)
logger.info("Update in course is a recovery update")