-
Notifications
You must be signed in to change notification settings - Fork 3
/
notify.py
55 lines (45 loc) · 1.48 KB
/
notify.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
#!/usr/bin/env python3
import os
from datetime import datetime
from typing import AnyStr
from winrt.windows.data.xml import dom
from winrt.windows.ui import notifications
def notify(message: AnyStr):
"""Creates a Native Toast on Windows
Args:
message (AnyStr): Toast Message
"""
# appID of Task Scheduler
appID = "Microsoft.AutoGenerated.{C1C6F8AC-40A3-0F5C-146F-65A9DC70BBB4}"
# Create notifier
nManager = notifications.ToastNotificationManager
notifier = nManager.create_toast_notifier(appID)
# Define your notification as string
tString = f"""
<toast launch="{appID}">
<visual>
<binding template="ToastGeneric">
<text>Status of Running Get DNAC Device List</text>
<text>{message}</text>
<text placement="attribution">Notification via Visual Studio Code</text>
<image placement="appLogoOverride" src="{os.path.abspath('assets/vscode-logo.png')}"/>
<group>
<subgroup>
<text hint-style="captionSubtle" hint-align="left">{datetime.now().strftime('%b %d %Y %H:%M:%S')}</text>
</subgroup>
</group>
</binding>
</visual>
<actions>
<action
content="Dismiss"
arguments="dismiss"
activationType="background"/>
</actions>
</toast>
"""
# Convert notification to an XmlDocument
xDoc = dom.XmlDocument()
xDoc.load_xml(tString)
# Display notification
notifier.show(notifications.ToastNotification(xDoc))