jssimporter / Spruce

Spruce is deprecated. Please see the wiki for alternatives.
GNU General Public License v3.0
149 stars 22 forks source link

DeleteError response handling #43

Open smashism opened 5 years ago

smashism commented 5 years ago

When trying to remove packages, spruce will eventually fail and exit with an error code when there are 404 responses. It seems to be unable to handle a 404 after the removal of the package, but during the check phase it seems to work fine.

Example:


JSS: https://jssserver.com
Preferences used: ~/Library/Preferences/com.github.autopkg.plist
Are you sure you want to continue deleting objects from https://jssserver.com? (Y or N): y
Package object Firefox-67.0.2.pkg with ID 511 is not available or does not exist.
Status Code: 404
Error: Response Code: 404   Response: Not Found. The server has not found anything matching the request URI https://jssserver.com/JSSResource/packages/id/511.
Package object Firefox-67.0.3.pkg with ID 531 is not available or does not exist.
Status Code: 404
Error: Response Code: 404   Response: Not Found. The server has not found anything matching the request URI https://jssserver.com/JSSResource/packages/id/531.
Package object Firefox-67.0.4.pkg with ID 535 is not available or does not exist.
Status Code: 404
Error: Response Code: 404   Response: Not Found. The server has not found anything matching the request URI https://jssserver.com/JSSResource/packages/id/535.
Package object 462: Firefox-67.0.pkg deleted.
Package file Firefox-67.0.pkg deleted.
Package object 583: Firefox-68.0.1.pkg deleted.
Package object 568: Firefox-68.0.pkg deleted.
Traceback (most recent call last):
  File "/AutoPkg/Spruce-master/spruce.py", line 2054, in <module>
    main()
  File "/AutoPkg/Spruce-master/spruce.py", line 2048, in main
    remove(removal_tree)
  File "/AutoPkg/Spruce-master/spruce.py", line 1976, in remove
    jss_connection.distribution_points.delete(filename)
  File "/Library/Application Support/JSSImporter/jss/distribution_points.py", line 272, in delete
    repo.delete(filename)
  File "/Library/Application Support/JSSImporter/jss/distribution_point.py", line 724, in delete
    self.connection["jss"].Package(filename).delete()
  File "/Library/Application Support/JSSImporter/jss/jssobject.py", line 702, in delete
    self.jss.delete(self.url)
  File "/Library/Application Support/JSSImporter/jss/jamf_software_server.py", line 452, in delete
    error_handler(DeleteError, response)
  File "/Library/Application Support/JSSImporter/jss/tools.py", line 94, in error_handler
    raise exception
jss.exceptions.DeleteError: Response Code: 404  Response: Not Found. The server has not found anything matching the request URI https://jssserver.com/JSSResource/packages/id/568.```
grahampugh commented 5 years ago

I found one instance of JSSDeleteError in spruce.py, which changed to DeleteError in recent python-jss. I've corrected this - can you check the latest commit?

grahampugh commented 5 years ago

(note this won't address your 404s, but might prevent the Tracebacks.)