univ-of-utah-marriott-library-apple / jctl

`jctl` uses `python-jamf` to select objects to create, delete, print and update. It allows performing Jamf Pro repetitive tasks quickly and provides options not available in the web GUI. It is similar to SQL statements, but far less complex.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Errors when executing `jctl packages -S usage`

dan-snelson opened this issue · comments

In limited testing, I’m observing the following errors when using jctl packages -S usage:

% sw_vers
ProductName:	macOS
ProductVersion:	11.6.1
BuildVersion:	20G224

% python3 --version
Python 3.10.0

% jctl patchsoftwaretitles -S patchpolicies 
…
Citrix Workspace
 Citrix Workspace Automatic
…
Microsoft Office 2019 (msupdate)
 Microsoft Office 2019 (msupdate) Beta Tester
 Microsoft Office 2019 (msupdate) Automatic
…
VMware Fusion 12
 VMware Fusion 12 Self Service
Zoom Client for Meetings
 Zoom Client for Meetings Beta Testers
 Zoom Client for Meetings Automatic
 Zoom Client for Meetings Self Service
…
Count: 31

% jctl packages -S usage 
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/jctl", line 547, in <module>
    main(sys.argv[1:])
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/jctl", line 401, in main
    method(record, *args.sub_command['args'])
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jamf/records.py", line 1093, in usage_print_during
    related = self.related
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jamf/records.py", line 1086, in related
    self.refresh_related()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jamf/records.py", line 1075, in refresh_related
    if re.search(".pkg|.zip|.dmg", pkg[-4:]):
TypeError: 'NoneType' object is not subscriptable

Also …

% jctl policies -S spreadsheet > ~/Desktop/policies.csv
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/jctl", line 547, in <module>
    main(sys.argv[1:])
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/jctl", line 401, in main
    method(record, *args.sub_command['args'])
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jamf/records.py", line 1296, in spreadsheet_print_during
    print(self.spreadsheet())
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jamf/records.py", line 1317, in spreadsheet
    if self.data['general']['trigger_logout'] == "true":
KeyError: 'trigger_logout'

Same experience with Python 3.7.5:

% python3 --version                        
Python 3.7.5

% jctl packages -S usage                                          
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/bin/jctl", line 547, in <module>
    main(sys.argv[1:])
  File "/Library/Frameworks/Python.framework/Versions/3.7/bin/jctl", line 401, in main
    method(record, *args.sub_command['args'])
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/jamf/records.py", line 1093, in usage_print_during
    related = self.related
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/jamf/records.py", line 1086, in related
    self.refresh_related()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/jamf/records.py", line 1075, in refresh_related
    if re.search(".pkg|.zip|.dmg", pkg[-4:]):
TypeError: 'NoneType' object is not subscriptable

@uurazzle was able to duplicate.

Dan, I released python-jamf 0.7.2 and it fixes this bug. jctl doesn't need to be updated to get the fix. Closing this issue.

@magnusviri Confirmed fixed.

% pip3 show python-jamf          
Name: python-jamf
Version: 0.7.2
% jctl packages -S usage
…
Citrix Workspace-21.11.0.pkg
  Policies
    Citrix Workspace (21.11.0)
  PatchPolicies
    Citrix Workspace Automatic
…
Count: 188

I'm getting the same error today

jctl -v
jctl 1.1.22
python_jamf 0.9.4 (0.9.0 required)
jctl packages
IntelliJIDEA-2021.2.pkg
SourceTree-4.0.1.pkg
SourceTree-4.0.2.pkg
Spotify-1.1.63.568.pkg
TeamViewerQS-15.6.7.pkg
TeamViewerQS-15.7.6.pkg
TeamViewerQS-15.8.3.pkg
TeamViewerQS-15.9.4.pkg
VisualStudioCode-1.48.2.pkg
Vysor-2.1.2.pkg
Vysor-2.3.1.pkg
Vysor-4.1.25.pkg
Zeplin-3.7.1.pkg
Zeplin-3.7.pkg
Zoom-5.4.59301.1211.pkg
Zoom-5.4.59931.0110.pkg
terminal-notifier-2.0.0.pkg
Count: 17
❯ jctl packages -S usage
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/jctl", line 745, in <module>
    main(sys.argv[1:])
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/jctl", line 648, in main
    print_feedback(record, args, outputer, rec_class)
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/jctl", line 558, in print_feedback
    method(record, *args.sub_command["args"])
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/python_jamf/records.py", line 1423, in usage_print_during
    related = self.related
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/python_jamf/records.py", line 1416, in related
    self.refresh_related()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/python_jamf/records.py", line 1410, in refresh_related
    self.refresh_groups(related)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/python_jamf/records.py", line 1385, in refresh_groups
    for criteria in criterions:
TypeError: 'NoneType' object is not iterable

I also get Dan's error with jctl policies -S spreadsheet > ~/Desktop/policies.csv

jctl policies -S spreadsheet > ~/Desktop/policies.csv
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/jctl", line 745, in <module>
    main(sys.argv[1:])
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/jctl", line 648, in main
    print_feedback(record, args, outputer, rec_class)
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/jctl", line 558, in print_feedback
    method(record, *args.sub_command["args"])
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/python_jamf/records.py", line 1746, in spreadsheet_print_during
    print(self.spreadsheet())
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/python_jamf/records.py", line 1802, in spreadsheet
    if self.data["package_configuration"]["packages"]["size"] != "0":
KeyError: 'packages'

Tony,
The first error was fixed in 0.9.5. You have 0.9.4.

univ-of-utah-marriott-library-apple/python-jamf@23a2520

The second error is new to me. I just released a fix, 0.9.8.

pip install --upgrade python-jamf

Thanks for reporting these bugs!