示例#1
0
 def test_to_string(self):
     for known_string, known_encoding in self.examples:
         obj = ObjectIdentifier(known_encoding)
         string = str(obj)
         print(known_string, binascii.hexlify(known_encoding), string)
         self.assertEqual(known_string, string)
     with self.assertRaises(AssertionError):
         ObjectIdentifier.from_string('3.0')
     with self.assertRaises(AssertionError):
         ObjectIdentifier.from_string('1.41')
示例#2
0
文件: pdus.py 项目: b1tninja/snmpy
 def from_oid(cls, oid=None):
     if oid is None:
         oid = snmp.mib.system
     if isinstance(oid, str):
         oid = ObjectIdentifier.from_string(oid)
     if isinstance(oid, ObjectIdentifier):
         oid = oid.get_object()
     else:
         assert isinstance(oid, Object)
         assert isinstance(oid.value, ObjectIdentifier)
     variable_bindings = Sequence.from_list([Sequence.from_list([oid, Null().get_object()])])
     return cls(variable_bindings=variable_bindings)
示例#3
0
文件: pdus.py 项目: b1tninja/snmpy
 def from_oid(cls, oid=None):
     if oid is None:
         oid = snmp.mib.system
     if isinstance(oid, str):
         oid = ObjectIdentifier.from_string(oid)
     if isinstance(oid, ObjectIdentifier):
         oid = oid.get_object()
     else:
         assert isinstance(oid, Object)
         assert isinstance(oid.value, ObjectIdentifier)
     variable_bindings = Sequence.from_list([Sequence.from_list([oid, Null().get_object()])])
     return cls(variable_bindings=variable_bindings)
示例#4
0
 def test_from_string(self):
     for known_string, known_encoding in self.examples:
         print(known_string, binascii.hexlify(known_encoding))
         obj = ObjectIdentifier.from_string(known_string)
         encoding = bytes(obj)
         self.assertEqual(known_encoding, encoding)
示例#5
0
from ber.object import ObjectIdentifier

# 1 - ISO assigned OIDs
# 1.3 - ISO Identified Organization
# 1.3.6 - US Department of Defense
# 1.3.6.1 - OID assignments from 1.3.6.1 - Internet
# 1.3.6.1.2 - IETF Management
# 1.3.6.1.2.1 - SNMP MIB-2

system = ObjectIdentifier.from_string('1.3.6.1.2.1')