forked from pbowden-msft/ExtensionAttributes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOutlook_Zoom_Version.xml
68 lines (59 loc) · 2.17 KB
/
Outlook_Zoom_Version.xml
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
<?xml version="1.0" encoding="UTF-8"?><extensionAttribute>
<displayName>Outlook Zoom Version</displayName>
<description/>
<dataType>string</dataType>
<scriptContentsMac>
#!/usr/bin/python
import glob
import HTMLParser
import os
import re
import sys
from os.path import expanduser
from SystemConfiguration import SCDynamicStoreCopyConsoleUser
def get_console_user():
username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]
username = [username,""][username in [u"loginwindow", None, u""]]
return username
def does_folder_exist(path):
return os.path.isdir(path)
def get_home_folder(username):
home_folder = expanduser('~' + str(username))
if does_folder_exist(home_folder):
return home_folder
return None
def get_outlook_log_filename(home_folder):
log_folder = os.path.join(home_folder, 'Library/Containers/com.microsoft.Outlook/Data/Library/Caches/Microsoft/uls/com.microsoft.Outlook/logs')
if does_folder_exist(log_folder):
log_files = glob.glob(log_folder + '/*.log')
if len(log_files) != 0:
return str(log_files[0])
return None
def grep_outlook_log(filename):
with open(filename) as log_file:
for line in log_file:
zoom = re.findall(r'Zoom Plugin Version', line)
valid = re.findall(r'"ZoomPlugInVersion"', line)
invalid = re.findall(r'Invalid Zoom Plugin Version found', line)
ver = re.findall(r'"([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})"', line)
if zoom and invalid:
return str('[blocked]')
if zoom and ver and valid:
return str(ver[0])
return 'Not present'
## MAIN
console_user = get_console_user()
zoom_version = 'Not present'
if console_user:
home_folder = get_home_folder(console_user)
if home_folder:
outlook_log = get_outlook_log_filename(home_folder)
if outlook_log:
zoom_version = grep_outlook_log(outlook_log)
html_parser = HTMLParser.HTMLParser()
result = html_parser.unescape('<result>') + str(zoom_version) + html_parser.unescape('</result>')
print(result)
sys.exit(0)
</scriptContentsMac>
<scriptContentsWindows/>
</extensionAttribute>