当前位置: 首页>>代码示例>>Python>>正文


Python rfc1902.OctetString方法代码示例

本文整理汇总了Python中pysnmp.proto.rfc1902.OctetString方法的典型用法代码示例。如果您正苦于以下问题:Python rfc1902.OctetString方法的具体用法?Python rfc1902.OctetString怎么用?Python rfc1902.OctetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pysnmp.proto.rfc1902的用法示例。


在下文中一共展示了rfc1902.OctetString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parse

# 需要导入模块: from pysnmp.proto import rfc1902 [as 别名]
# 或者: from pysnmp.proto.rfc1902 import OctetString [as 别名]
def parse(self, line):

        filters = {
            'OctetString': self._stringFilter
        }

        try:
            oid, tag, value = [x.strip() for x in octs2str(line).split(',', 2)]

        except Exception as exc:
            raise error.SnmpsimError(
                'broken record <%s>: %s' % (line, exc))

        else:
            if oid and tag:
                handler = filters.get(tag, lambda x: x)
                return oid, tag, handler(value.strip())

            raise error.SnmpsimError('broken record <%s>' % line) 
开发者ID:etingof,项目名称:snmpsim,代码行数:21,代码来源:sap.py

示例2: probe_context

# 需要导入模块: from pysnmp.proto import rfc1902 [as 别名]
# 或者: from pysnmp.proto.rfc1902 import OctetString [as 别名]
def probe_context(transport_domain, transport_address,
                  context_engine_id, context_name):
    """Suggest variations of context name based on request data
    """
    if context_engine_id:
        candidate = [
            context_engine_id, context_name, '.'.join(
                [str(x) for x in transport_domain])]

    else:
        # try legacy layout w/o contextEngineId in the path
        candidate = [
            context_name, '.'.join(
                [str(x) for x in transport_domain])]

    if transport_domain[:len(udp.domainName)] == udp.domainName:
        candidate.append(transport_address[0])

    elif udp6 and transport_domain[:len(udp6.domainName)] == udp6.domainName:
        candidate.append(str(transport_address[0]).replace(':', '_'))

    elif unix and transport_domain[:len(unix.domainName)] == unix.domainName:
        candidate.append(transport_address)

    candidate = [str(x) for x in candidate if x]

    while candidate:
        yield rfc1902.OctetString(
            os.path.normpath(
                os.path.sep.join(candidate)).replace(os.path.sep, '/')).asOctets()
        del candidate[-1]

    # try legacy layout w/o contextEngineId in the path
    if context_engine_id:
        for candidate in probe_context(
                transport_domain, transport_address, None, context_name):
            yield candidate 
开发者ID:etingof,项目名称:snmpsim,代码行数:39,代码来源:datafile.py

示例3: hexify_value

# 需要导入模块: from pysnmp.proto import rfc1902 [as 别名]
# 或者: from pysnmp.proto.rfc1902 import OctetString [as 别名]
def hexify_value(self, value):
        if value.tagSet in (univ.OctetString.tagSet,
                            rfc1902.Opaque.tagSet,
                            rfc1902.IpAddress.tagSet):

            nval = value.asNumbers()

            for x in nval:
                if (value.tagSet == rfc1902.IpAddress.tagSet or
                            x not in self.ALNUMS):
                    return ''.join(['%.2x' % x for x in nval]) 
开发者ID:etingof,项目名称:snmpsim,代码行数:13,代码来源:snmprec.py

示例4: add_data_file

# 需要导入模块: from pysnmp.proto import rfc1902 [as 别名]
# 或者: from pysnmp.proto.rfc1902 import OctetString [as 别名]
def add_data_file(self, *args):
        for idx in range(len(args)):
            self._db[
                self._index_oid + (idx + 1, self._idx)
                ] = rfc1902.OctetString(args[idx])
        self._idx += 1 
开发者ID:etingof,项目名称:snmpsim,代码行数:8,代码来源:controller.py

示例5: set_snmp_single

# 需要导入模块: from pysnmp.proto import rfc1902 [as 别名]
# 或者: from pysnmp.proto.rfc1902 import OctetString [as 别名]
def set_snmp_single(rwstring, ip_address, ifAlias, description):
    from pysnmp.entity.rfc3413.oneliner import cmdgen
    from pysnmp.proto import rfc1902
    cmdGen = cmdgen.CommandGenerator()
    cmdGen.setCmd(
        cmdgen.CommunityData(rwstring),
        cmdgen.UdpTransportTarget((ip_address, 161)),
        (ifAlias, rfc1902.OctetString(description))) 
开发者ID:HPENetworking,项目名称:PYHPEIMC,代码行数:10,代码来源:8 HP_IMC_Set_Interface_Descriptions.py

示例6: checkoctetstring

# 需要导入模块: from pysnmp.proto import rfc1902 [as 别名]
# 或者: from pysnmp.proto.rfc1902 import OctetString [as 别名]
def checkoctetstring(val):
        """
        Check for OctetString
        Arguments:
            1.val: pysnmp object
        :return: True or False
        """
        if isinstance(val, OctetString):
            return True
        else:
            return False

    ##TRAP Listner related method
    ## This will support SNMP v1 v2 V3 Trap and Inform as well 
开发者ID:warriorframework,项目名称:warriorframework,代码行数:16,代码来源:snmp_utlity_class.py

示例7: add_user

# 需要导入模块: from pysnmp.proto import rfc1902 [as 别名]
# 或者: from pysnmp.proto.rfc1902 import OctetString [as 别名]
def add_user(cls, port, username, securityengineid,
                 authkey=None, privkey=None,
                 authProtocol=None, privProtocol=None):
        """
        Add SNMP V3 User
        :param port: SNMP Trap Port
        :param username: SNMP User name
        :param securityengineid: SNMP Engine id in Hex form
        :param authkey: SNMP Authkey default is None
        :param privkey: SNMP Privkey string default is None
        :param authProtocol: Auth Protocol, default is None
        :param privProtocol: Privacy Protocol, default is None
        :return: Treu or False
        """
        result = True
        snmpEngine = cls.get_asyncoredispatcher(port)
        # debug.setLogger(debug.Debug('all'))
        try:
            authprotocol = cls.authProtocol.get(authProtocol, None)
            privprotocol = cls.authProtocol.get(privProtocol, None)
            config.addV3User(
                snmpEngine=snmpEngine, userName=username,
                authProtocol=authprotocol, authKey=authkey,
                privProtocol=privprotocol, privKey=privkey,
                securityEngineId=v2c.OctetString(hexValue=securityengineid)
            )
        except:
            testcase_Utils.pNote("ADD SNMPv3 User Failed", "error")
            result = False
        return result 
开发者ID:warriorframework,项目名称:warriorframework,代码行数:32,代码来源:snmp_utlity_class.py

示例8:

# 需要导入模块: from pysnmp.proto import rfc1902 [as 别名]
# 或者: from pysnmp.proto.rfc1902 import OctetString [as 别名]
def ft自动(a绑定变量):
	"""自动转换成python内置类型"""
	v变量 = a绑定变量[1]
	v类型 = type(v变量)
	if v类型 in (类型.OctetString, 类型.OctetString):	#字符串
		return str(v变量)
	elif v类型 in (类型.Integer, 类型.Integer32, 类型.Counter32, 类型.Counter64, 类型.Unsigned32, 类型.Gauge32):	#整数
		return int(v变量)
	elif v类型 == 类型.Null:	#空
		return None
	else:	#默认处理
		return str(v变量) 
开发者ID:cflw,项目名称:cflw_py,代码行数:14,代码来源:cflw简单网管_派.py


注:本文中的pysnmp.proto.rfc1902.OctetString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。