Skip to content

Commit

Permalink
Update adv_agentx.py
Browse files Browse the repository at this point in the history
with locale Fix from carosio#8
  • Loading branch information
Wolffy committed Dec 13, 2021
1 parent bea34e3 commit c3ed941
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion adv_agentx.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import os
import sys
import socket # for inet_aton
import locale

# export names
__all__ = [
Expand Down Expand Up @@ -310,6 +311,10 @@ def ReadTOID(oid):
axl.snprint_objid(strOID, OID_LEN, oid, len(oid))
return strOID.value

def b(s):
""" Encodes Unicode strings to byte strings, if necessary. """
return s if isinstance(s, bytes) else s.encode(locale.getpreferredencoding())

# exceptions


Expand Down Expand Up @@ -598,7 +603,7 @@ def __init__(self, Globals, **args):
if not type(self.MIBFile) in (list, tuple):
self.MIBFile = (self.MIBFile,)
for mib in self.MIBFile:
axl.read_mib(mib)
axl.read_mib(b(mib))

# install low level handler
if self.RootOID:
Expand Down

0 comments on commit c3ed941

Please sign in to comment.