jbloomer / SnipeIT-PythonAPI

Python Interface to the SnipeIT (https://github.com/snipe/snipe-it) API
80 stars 37 forks source link

Many 'ID' modules return a 'referenced before assignment' error. #4

Closed mforma-zenoss closed 6 years ago

mforma-zenoss commented 6 years ago

For example, the AssetGetIDRequestExample.py (with appropriate URL/token/variable substitutions) returns: Traceback (most recent call last): File "getAssetID.py", line 9, in <module> r = A.getID(server, token, "121") File "/home/username/.local/lib/python2.7/site-packages/snipeit/Assets.py", line 54, in getID return AssetID UnboundLocalError: local variable 'AssetID' referenced before assignment

And UsersGetIDRequestExample.py returns: Traceback (most recent call last): File "userid.py", line 9, in <module> r = U.getID(server, token, "valid_username") File "/home/username/.local/lib/python2.7/site-packages/snipeit/Users.py", line 53, in getID return UserID UnboundLocalError: local variable 'UserID' referenced before assignment

Some of the 'more global' calls do return json data as expected. Have tried in python 2.7, and python 3, against our internal Snipe instance which is on v4.1.0 build beta2 (g3b498ef)

jbloomer commented 6 years ago

I did not get those errors when I developed the code using Python 2.7.

What are you doing that is causing these errors? How can I replicate the errors you are getting?

mforma-zenoss commented 6 years ago

I was just starting to test with your methods, was all. The only changes I made to the two referenced files was to substitute in my own URL/API token, and to provide them with known-valid data for the searches.

I'm honestly not sure what would be different in your setup vs mine, frankly. I'll do some additional testing and see if I can replicate it in a clean python venv on another box. :)

mforma-zenoss commented 6 years ago

After creating a fresh venv, I can't seem to replicate this behavior any longer. Sorry! :)

jbloomer commented 6 years ago

Sure. Thanks for the follow up and confirmation