Try to fix unicode() changed name
This commit is contained in:
parent
38b9417cde
commit
b38c35ab76
1 changed files with 12 additions and 6 deletions
|
|
@ -1,11 +1,20 @@
|
||||||
from netbox_agent.config import netbox_instance as nb
|
from netbox_agent.config import netbox_instance as nb
|
||||||
from slugify import slugify
|
|
||||||
from shutil import which
|
from shutil import which
|
||||||
import subprocess
|
import subprocess
|
||||||
import socket
|
import socket
|
||||||
import re
|
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):
|
def is_tool(name):
|
||||||
'''Check whether `name` is on PATH and marked as executable.'''
|
'''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):
|
def get_device_platform(device_platform):
|
||||||
"""
|
|
||||||
if device_platform is None:
|
if device_platform is None:
|
||||||
try:
|
try:
|
||||||
# Python 3.8+ moved linux_distribution() to distro
|
# Python 3.8+ moved linux_distribution() to distro
|
||||||
|
|
@ -54,9 +62,9 @@ def get_device_platform(device_platform):
|
||||||
device_platform = nb.dcim.platforms.create(
|
device_platform = nb.dcim.platforms.create(
|
||||||
name=linux_distribution, slug=slugify(linux_distribution)
|
name=linux_distribution, slug=slugify(linux_distribution)
|
||||||
)
|
)
|
||||||
"""
|
|
||||||
return device_platform
|
return device_platform
|
||||||
|
|
||||||
|
|
||||||
def get_vendor(name):
|
def get_vendor(name):
|
||||||
vendors = {
|
vendors = {
|
||||||
'PERC': 'Dell',
|
'PERC': 'Dell',
|
||||||
|
|
@ -115,5 +123,3 @@ def get_mount_points():
|
||||||
mp = mount_info[2]
|
mp = mount_info[2]
|
||||||
mount_points.setdefault(device, []).append(mp)
|
mount_points.setdefault(device, []).append(mp)
|
||||||
return mount_points
|
return mount_points
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue