-
Notifications
You must be signed in to change notification settings - Fork 3
/
ignored_softwareupdates.py
executable file
·49 lines (36 loc) · 1.16 KB
/
ignored_softwareupdates.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
#!/usr/bin/env python
# Note - This EA is not being updated to Python 3 as `--ignore`` no longer works on newer macOS versions
"""
Jamf Pro extension attribute to return a list of ignored softwareupdates added
by using something like `softwareupdate --ignore "Security Update 2019-001"
Useful to manage ignored software updates by scoping smart groups to specific
updates as needed.
"""
import subprocess
def main():
"""Returns list of ignored software updates"""
result = "None"
updates = []
try:
proc = subprocess.Popen(
["/usr/sbin/softwareupdate", "--ignore"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
stdout, _ = proc.communicate()
except (IOError, OSError):
stdout = None
d = str(stdout.split("(", 1)[-1].rsplit(")", 1)[0])
if d.isspace():
result = None
else:
d = [x.strip() for x in d.split(",")]
for swu in d:
swu = swu.strip('"')
updates.append(swu)
if not updates:
updates.append("None")
result = "\n".join(updates)
print("<result>%s</result>" % result)
if __name__ == "__main__":
main()