netbox-community / Device-Type-Library-Import

This library is intended to assist with importing device and module types into NetBox from the NetBox Community DeviceType-Library
https://github.com/netbox-community/devicetype-library
MIT License
246 stars 74 forks source link

Traceback when running the script #119

Closed BaktashGorgani closed 6 months ago

BaktashGorgani commented 7 months ago

It doesn't seem to do anything for me but fail right away. I am fairly new to Netbox though so I would appreciate any assistance.

$./nb-dt-import.py
Package devicetype-library is already installed, updating C:\Users\baky\Git\tests\nornir\Device-Type-Library-Import/repo
114 Vendors Found
Traceback (most recent call last):
  File "C:\Users\baky\Git\tests\nornir\Device-Type-Library-Import\nb-dt-import.py", line 54, in <module>
    main()
  File "C:\Users\baky\Git\tests\nornir\Device-Type-Library-Import\nb-dt-import.py", line 22, in main
    device_types = settings.dtl_repo.parse_files(files, slugs=args.slugs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\baky\Git\tests\nornir\Device-Type-Library-Import\repo.py", line 90, in parse_files
    data = yaml.safe_load(stream)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\baky\Git\tests\nornir\Device-Type-Library-Import\venv\Lib\site-packages\yaml\__init__.py", line 125, in safe_load
    return load(stream, SafeLoader)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\baky\Git\tests\nornir\Device-Type-Library-Import\venv\Lib\site-packages\yaml\__init__.py", line 79, in load
    loader = Loader(stream)
             ^^^^^^^^^^^^^^
  File "C:\Users\baky\Git\tests\nornir\Device-Type-Library-Import\venv\Lib\site-packages\yaml\loader.py", line 34, in __init__
    Reader.__init__(self, stream)
  File "C:\Users\baky\Git\tests\nornir\Device-Type-Library-Import\venv\Lib\site-packages\yaml\reader.py", line 85, in __init__
    self.determine_encoding()
  File "C:\Users\baky\Git\tests\nornir\Device-Type-Library-Import\venv\Lib\site-packages\yaml\reader.py", line 124, in determine_encoding
    self.update_raw()
  File "C:\Users\baky\Git\tests\nornir\Device-Type-Library-Import\venv\Lib\site-packages\yaml\reader.py", line 178, in update_raw
    data = self.stream.read(size)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 344: character maps to <undefined>
ndom91 commented 6 months ago

This seems like a windows specific issue. Check out the python script someone has added for windows users specifically. Unfortunately the PR is still open, but you can pull it out of there already if you want - https://github.com/netbox-community/Device-Type-Library-Import/pull/86

BaktashGorgani commented 6 months ago

Hey thanks @ndom91 ! I'll take a look at it when I have a chance.