bradschm / jss-assettag-importer

JSS Asset Tag Importer - Get those asset tags into your Casper JSS. For Mobile Devices and Computers!
MIT License
16 stars 4 forks source link

Error Messages trying to run #1

Open NickyNewp opened 8 years ago

NickyNewp commented 8 years ago

I could use some help figuring out what I am doing wrong here. I heard you speak about this at JNUC and just got around to trying it and I'm having issues. Here is what I am getting back.

---Finished importing asset tags for Computers--- Traceback (most recent call last): File "jss-assettag-importer.py", line 226, in computers() File "jss-assettag-importer.py", line 119, in computers computersTotal = len(computers) TypeError: object of type 'NoneType' has no len()

bradschm commented 8 years ago

Do you have any mobile devices in your JSS? Did the asset tags import for the computers?

NickyNewp commented 8 years ago

Yes, we have a lot of mobile devices. My spreadsheet only had three asset tags and serials in it, which were all mobile devices. I was just testing the script with a few. The account I created looks like it has the correct permissions for mobile devices.

bradschm commented 8 years ago

If you comment the computers() line with a # it should run ok. I will add some better error handling and the ability to turn off one of the functions if it is not in use.

NickyNewp commented 8 years ago

I tried that and still received an error, but it did import. This is what came back to me.

Traceback (most recent call last): File "jss-assettag.py", line 227 in mobileDevices() File "jss-assettag-importer.py", line 98, in mobileDevices mobileDevicesTotal = len(mobileDevices) TypeError: object of type 'NoneType' has no len()

NickyNewp commented 8 years ago

Should I continue with the full import even with the error?

bradschm commented 8 years ago

I think it is now displaying that because the asset tags you have in the sheet have been imported. I am fairly confident it is displaying that because the list is empty. I need to add some error handling for that.

Brad Schmidt

On Tue, Feb 2, 2016 at 1:11 PM, NickyNewp notifications@github.com wrote:

Should I continue with the full import even with the error?

— Reply to this email directly or view it on GitHub https://github.com/bradschm/jss-assettag-importer/issues/1#issuecomment-178764484 .

bradschm commented 8 years ago

I updated the code to include those checks. It will now tell you if the group is empty and you can also turn on/off computer/mobile device modes. Let me know if that will work in your environment.

NickyNewp commented 8 years ago

I will give it a shot tomorrow and let you know. I really appreciate all of your help!

packetrich commented 8 years ago

Thanks for the code Brad! Sorry to bring up an old post, but I think I found out why it didn't work for NickyNewp.

I'm running JSS 9.92 and I ran into the same issue with v.2, but I was only looking to update computers not mobile devices. I left "computersMode = True" and commented out the others. On the JSS I manually created a "_API-Asset-Tag-Importer" smart group and set the criteria to "(blank) Asset Tag (is) and (blank)" and saved it.

The script ran through all through my computer assets that didn't have asset tags and updated everything correctly. It still choked at the end on the mobile devices with the same errors as the top of the post, but I didn't need/create a smart group for mobile, so all was good.

I haven't figured out why the smart groups weren't created in the first place, but I'll check into it some more since I want to see if I can expand the code to update user and location information as well.

bradschm commented 8 years ago

Hi @packetrich,

Did you comment the false line out too? That might be the error on that.

I think I see the issue with the group creation, I had it looking for length on a NoneType. I'll switch the logic and do a commit.

Thanks for the feedback!

bradschm commented 8 years ago

Hi @packetrich and @NickyNewp,

Please give the new code a try. I cleaned it up and fixed it so it will create the group properly.

Let me know how it goes.

Thanks, Brad

packetrich commented 8 years ago

@bradschm I tried to use the new code but it throws an error:

Traceback (most recent call last): File "jss-assettag-importer.py", line 3, in import requests ImportError: No module named requests

bradschm commented 8 years ago

@packetrich You will need the requests library. You can get that by running:

If you have pip installed, type: sudo pip install -r requirements.txt If you don't have pip you can use easyInstall to get pip: sudo easy_install pip then run sudo pip install -r requirements.txt

Thanks!