示例#1
0
    elif opt[0] == '--variation-module-options':
        variationModuleOptions = opt[1]

if params:
    sys.stderr.write('ERROR: extra arguments supplied %s\r\n%s\r\n' %
                     (params, helpMessage))
    sys.exit(-1)

if not pcap:
    sys.stderr.write(
        'ERROR: pylibpcap package is missing!\r\nGet it by running `pip install https://downloads.sourceforge.net/project/pylibpcap/pylibpcap/0.6.4/pylibpcap-0.6.4.tar.gz`\r\n%s\r\n'
        % helpMessage)
    sys.exit(-1)

try:
    log.setLogger(PROGRAM_NAME, *loggingMethod, force=True)

    if loggingLevel:
        log.setLevel(loggingLevel)

except error.SnmpsimError:
    sys.stderr.write('%s\r\n%s\r\n' % (sys.exc_info()[1], helpMessage))
    sys.exit(1)

if isinstance(startOID, rfc1902.ObjectIdentity) or \
        isinstance(stopOID, rfc1902.ObjectIdentity):
    mibBuilder = builder.MibBuilder()

    mibViewController = view.MibViewController(mibBuilder)

    compiler.addMibCompiler(mibBuilder,
示例#2
0
""" % (snmpsim.__version__, hasattr(pysmi, '__version__') and pysmi.__version__
        or 'unknown', hasattr(pysnmp, '__version__') and pysnmp.__version__
        or 'unknown', hasattr(pyasn1, '__version__') and pyasn1.__version__
        or 'unknown', sys.version, helpMessage))
        sys.exit(-1)
    elif opt[0] in ('--debug', '--debug-snmp'):
        pysnmp_debug.setLogger(
            pysnmp_debug.Debug(*opt[1].split(','),
                               **dict(loggerName='pcap2dev.pysnmp')))
    elif opt[0] == '--debug-asn1':
        pyasn1_debug.setLogger(
            pyasn1_debug.Debug(*opt[1].split(','),
                               **dict(loggerName='pcap2dev.pyasn1')))
    elif opt[0] == '--logging-method':
        try:
            log.setLogger('pcap2dev', *opt[1].split(':'), **dict(force=True))
        except error.SnmpsimError:
            sys.stderr.write('%s\r\n%s\r\n' % (sys.exc_info()[1], helpMessage))
            sys.exit(-1)
    if opt[0] == '--quiet':
        verboseFlag = False
    # obsolete begin
    elif opt[0] == '--start-oid':
        startOID = univ.ObjectIdentifier(opt[1])
    elif opt[0] == '--stop-oid':
        stopOID = univ.ObjectIdentifier(opt[1])
    # obsolete end
    if opt[0] == '--mib-source':
        mibSources.append(opt[1])
    if opt[0] == '--start-object':
        startOID = rfc1902.ObjectIdentity(*opt[1].split('::', 1))
示例#3
0
     or 'unknown', sys.version, helpMessage))
     sys.exit(-1)
 elif opt[0] in ('--debug', '--debug-snmp'):
     pysnmp_debug.setLogger(
         pysnmp_debug.Debug(*opt[1].split(','),
                            **dict(loggerName='snmprec.pysnmp')))
 elif opt[0] == '--debug-asn1':
     pyasn1_debug.setLogger(
         pyasn1_debug.Debug(*opt[1].split(','),
                            **dict(loggerName='snmprec.pyasn1')))
 elif opt[0] == '--logging-method':
     loggingMethod = opt[1].split(':')
 elif opt[0] == '--log-level':
     loggingLevel = opt[1]
 elif opt[0] == '--quiet':
     log.setLogger('snmprec', 'null', force=True)
 elif opt[0] == '--v1':
     snmpVersion = 0
 elif opt[0] == '--v2c':
     snmpVersion = 1
 elif opt[0] == '--v3':
     snmpVersion = 3
 elif opt[0] == '--protocol-version':
     if opt[1] in ('1', 'v1'):
         snmpVersion = 0
     elif opt[1] in ('2', '2c', 'v2c'):
         snmpVersion = 1
     elif opt[1] in ('3', 'v3'):
         snmpVersion = 3
     else:
         sys.stderr.write('ERROR: unknown SNMP version %s\r\n%s\r\n' %
示例#4
0
""" % (snmpsim.__version__, hasattr(pysmi, '__version__') and pysmi.__version__
        or 'unknown', hasattr(pysnmp, '__version__') and pysnmp.__version__
        or 'unknown', hasattr(pyasn1, '__version__') and pyasn1.__version__
        or 'unknown', sys.version, helpMessage))
        sys.exit(-1)
    elif opt[0] in ('--debug', '--debug-snmp'):
        pysnmp_debug.setLogger(
            pysnmp_debug.Debug(*opt[1].split(','),
                               **dict(loggerName='snmprec.pysnmp')))
    elif opt[0] == '--debug-asn1':
        pyasn1_debug.setLogger(
            pyasn1_debug.Debug(*opt[1].split(','),
                               **dict(loggerName='snmprec.pyasn1')))
    elif opt[0] == '--logging-method':
        try:
            log.setLogger('snmprec', *opt[1].split(':'), **dict(force=True))
        except error.SnmpsimError:
            sys.stderr.write('%s\r\n%s\r\n' % (sys.exc_info()[1], helpMessage))
            sys.exit(-1)
    elif opt[0] == '--quiet':
        log.setLogger('snmprec', 'null', force=True)
    elif opt[0] == '--v1':
        snmpVersion = 0
    elif opt[0] == '--v2c':
        snmpVersion = 1
    elif opt[0] == '--v3':
        snmpVersion = 3
    elif opt[0] == '--protocol-version':
        if opt[1] in ('1', 'v1'):
            snmpVersion = 0
        elif opt[1] in ('2', '2c', 'v2c'):
示例#5
0
if params:
    sys.stderr.write(
        'ERROR: extra arguments supplied %s\r\n'
        '%s\r\n' % (params, helpMessage))
    sys.exit(-1)

if not pcap:
    sys.stderr.write(
        'ERROR: pylibpcap package is missing!\r\nGet it by running `pip install '
        'https://downloads.sourceforge.net/project/pylibpcap/pylibpcap/0.6.4/pylibpcap-0.6.4.tar.gz`'
        '\r\n%s\r\n' % helpMessage)
    sys.exit(-1)

try:
    log.setLogger(PROGRAM_NAME, *loggingMethod, force=True)

    if loggingLevel:
        log.setLevel(loggingLevel)

except error.SnmpsimError:
    sys.stderr.write(
        '%s\r\n%s\r\n' % (sys.exc_info()[1], helpMessage))
    sys.exit(1)

if (isinstance(startOID, rfc1902.ObjectIdentity) or
        isinstance(stopOID, rfc1902.ObjectIdentity)):
    mibBuilder = builder.MibBuilder()

    mibViewController = view.MibViewController(mibBuilder)
示例#6
0
            pysnmp_debug.Debug(
                *opt[1].split(','), **dict(loggerName='snmprec.pysnmp')))

    elif opt[0] == '--debug-asn1':
        pyasn1_debug.setLogger(
            pyasn1_debug.Debug(
                *opt[1].split(','), **dict(loggerName='snmprec.pyasn1')))

    elif opt[0] == '--logging-method':
        loggingMethod = opt[1].split(':')

    elif opt[0] == '--log-level':
        loggingLevel = opt[1]

    elif opt[0] == '--quiet':
        log.setLogger('snmprec', 'null', force=True)

    elif opt[0] == '--v1':
        snmpVersion = 0

    elif opt[0] == '--v2c':
        snmpVersion = 1

    elif opt[0] == '--v3':
        snmpVersion = 3

    elif opt[0] == '--protocol-version':
        if opt[1] in ('1', 'v1'):
            snmpVersion = 0

        elif opt[1] in ('2', '2c', 'v2c'):
示例#7
0
        import snmpsim, pysnmp, pysmi, pyasn1
        sys.stderr.write("""\
SNMP Simulator version %s, written by Ilya Etingof <*****@*****.**>
Using foundation libraries: pysmi %s, pysnmp %s, pyasn1 %s.
Python interpreter: %s
Software documentation and support at http://snmpsim.sf.net
%s
""" % (snmpsim.__version__, hasattr(pysmi, '__version__') and pysmi.__version__ or 'unknown', hasattr(pysnmp, '__version__') and pysnmp.__version__ or 'unknown', hasattr(pyasn1, '__version__') and pyasn1.__version__ or 'unknown', sys.version, helpMessage))
        sys.exit(-1)
    elif opt[0] in ('--debug', '--debug-snmp'):
        pysnmp_debug.setLogger(pysnmp_debug.Debug(*opt[1].split(','), **dict(loggerName='snmprec.pysnmp')))
    elif opt[0] == '--debug-asn1':
        pyasn1_debug.setLogger(pyasn1_debug.Debug(*opt[1].split(','), **dict(loggerName='snmprec.pyasn1')))
    elif opt[0] == '--logging-method':
        try:
            log.setLogger('snmprec', *opt[1].split(':'), **dict(force=True))
        except error.SnmpsimError:
            sys.stderr.write('%s\r\n%s\r\n' % (sys.exc_info()[1], helpMessage))
            sys.exit(-1)
    elif opt[0] == '--quiet':
        log.setLogger('snmprec', 'null', force=True) 
    elif opt[0] == '--v1':
        snmpVersion = 0
    elif opt[0] == '--v2c':
        snmpVersion = 1
    elif opt[0] == '--v3':
        snmpVersion = 3
    elif opt[0] == '--protocol-version':
        if opt[1] in ('1', 'v1'):
            snmpVersion = 0
        elif opt[1] in ('2', '2c', 'v2c'):
示例#8
0
        import snmpsim, pysmi, pysnmp, pyasn1
        sys.stderr.write("""\
SNMP Simulator version %s, written by Ilya Etingof <*****@*****.**>
Using foundation libraries: pysmi %s, pysnmp %s, pyasn1 %s.
Python interpreter: %s
Software documentation and support at http://snmpsim.sf.net
%s
""" % (snmpsim.__version__, hasattr(pysmi, '__version__') and pysmi.__version__ or 'unknown', hasattr(pysnmp, '__version__') and pysnmp.__version__ or 'unknown', hasattr(pyasn1, '__version__') and pyasn1.__version__ or 'unknown', sys.version, helpMessage))
        sys.exit(-1)
    elif opt[0] in ('--debug', '--debug-snmp'):
        pysnmp_debug.setLogger(pysnmp_debug.Debug(*opt[1].split(','), **dict(loggerName='pcap2dev.pysnmp')))
    elif opt[0] == '--debug-asn1':
        pyasn1_debug.setLogger(pyasn1_debug.Debug(*opt[1].split(','), **dict(loggerName='pcap2dev.pyasn1')))
    elif opt[0] == '--logging-method':
        try:
            log.setLogger('pcap2dev', *opt[1].split(':'), **dict(force=True))
        except error.SnmpsimError:
            sys.stderr.write('%s\r\n%s\r\n' % (sys.exc_info()[1], helpMessage))
            sys.exit(-1)
    if opt[0] == '--quiet':
        verboseFlag = False
    # obsolete begin
    elif opt[0] == '--start-oid':
        startOID = univ.ObjectIdentifier(opt[1])
    elif opt[0] == '--stop-oid':
        stopOID = univ.ObjectIdentifier(opt[1])
    # obsolete end
    if opt[0] == '--mib-source':
        mibSources.append(opt[1])
    if opt[0] == '--start-object':
        startOID = rfc1902.ObjectIdentity(*opt[1].split('::'))