Try to fix unicode() changed name

This commit is contained in:
Pierre Lannoy 2024-02-05 16:52:18 +01:00
commit b38c35ab76
Signed by: Pierre Lannoy
GPG key ID: D27231EF87D53F31

View file

@ -1,11 +1,20 @@
from netbox_agent.config import netbox_instance as nb
from slugify import slugify
from shutil import which
import subprocess
import socket
import re
import unicodedata
def slugify(string):
return re.sub(r'[-\s]+', '-',
str(
re.sub(r'[^\w\s-]', '',
unicodedata.normalize('NFKD', string)
.encode('ascii', 'ignore'))
.strip()
.lower()))
unicode = str
def is_tool(name):
'''Check whether `name` is on PATH and marked as executable.'''
@ -31,7 +40,6 @@ def get_device_type(type):
def get_device_platform(device_platform):
"""
if device_platform is None:
try:
# Python 3.8+ moved linux_distribution() to distro
@ -54,9 +62,9 @@ def get_device_platform(device_platform):
device_platform = nb.dcim.platforms.create(
name=linux_distribution, slug=slugify(linux_distribution)
)
"""
return device_platform
def get_vendor(name):
vendors = {
'PERC': 'Dell',
@ -115,5 +123,3 @@ def get_mount_points():
mp = mount_info[2]
mount_points.setdefault(device, []).append(mp)
return mount_points