-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathcheck_jamf_profiles.py
More file actions
39 lines (28 loc) · 1009 Bytes
/
Copy pathcheck_jamf_profiles.py
File metadata and controls
39 lines (28 loc) · 1009 Bytes
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
#!/usr/bin/python
"""Check Jamf scripts for common issues."""
import argparse
import plistlib
from xml.parsers.expat import ExpatError
def build_argument_parser() -> argparse.ArgumentParser:
"""Build and return the argument parser."""
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
)
parser.add_argument("filenames", nargs="*", help="Filenames to check.")
return parser
def main(argv: list[str] | None = None) -> int:
"""Main process."""
# Parse command line arguments.
argparser = build_argument_parser()
args = argparser.parse_args(argv)
retval = 0
for filename in args.filenames:
try:
with open(filename, "rb") as openfile:
_ = plistlib.load(openfile)
except (ExpatError, ValueError) as err:
print(f"{filename}: plist parsing error: {err}")
retval = 1
return retval
if __name__ == "__main__":
exit(main())