File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -444,14 +444,18 @@ def search_snipe_asset(serial):
444444 if response .status_code == 200 :
445445 jsonresponse = response .json ()
446446 # Check to make sure there's actually a result
447- if jsonresponse ['total' ] == 1 :
448- return jsonresponse
449- elif jsonresponse ['total' ] == 0 :
447+ if "total" in jsonresponse :
448+ if jsonresponse ['total' ] == 1 :
449+ return jsonresponse
450+ elif jsonresponse ['total' ] == 0 :
451+ logging .info ("No assets match {}" .format (serial ))
452+ return "NoMatch"
453+ else :
454+ logging .warning ('FOUND {} matching assets while searching for: {}' .format (jsonresponse ['total' ], serial ))
455+ return "MultiMatch"
456+ else :
450457 logging .info ("No assets match {}" .format (serial ))
451458 return "NoMatch"
452- else :
453- logging .warning ('FOUND {} matching assets while searching for: {}' .format (jsonresponse ['total' ], serial ))
454- return "MultiMatch"
455459 else :
456460 logging .warning ('Snipe-IT responded with error code:{} when we tried to look up: {}' .format (response .text , serial ))
457461 logging .debug ('{} - {}' .format (response .status_code , response .content ))
You can’t perform that action at this time.
0 commit comments