etingof / pysmi

SNMP MIB parser
http://snmplabs.com/pysmi/
BSD 2-Clause "Simplified" License
137 stars 52 forks source link

Missing source MIB #46

Closed FrogAtGithub closed 5 years ago

FrogAtGithub commented 5 years ago

Hi, Using a command prompt with Windows 10, with mibdump.py and MAV3-MIB.mib being in the same folder (C:/sandbox), i am running the following command :

C:\sandbox>mibdump.py MAV3-MIB.mib

It results in the following :

Source MIB repositories: file:///usr/share/snmp/mibs, http://mibs.snmplabs.com/asn1/@mib@
Borrow missing/failed MIBs from: http://mibs.snmplabs.com/pysnmp/notexts/@mib@
Existing/compiled MIB locations: pysnmp.smi.mibs, pysnmp_mibs
Compiled MIBs destination directory: C:\Users\SESA78282\PySNMP Configuration\mibs
MIBs excluded from code generation: INET-ADDRESS-MIB, PYSNMP-USM-MIB, RFC-1212, RFC-1215, RFC1065-SMI, RFC1155-SMI, RFC1158-MIB, RFC1213-MIB, SNMP-FRAMEWORK-MIB, SNMP-TARGET-MIB, SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC, SNMPv2-TM, TRANSPORT-ADDRESS-MIB
MIBs to compile: MAV3-MIB
Destination format: pysnmp
Custom destination template: None
Parser grammar cache directory: not used
Also compile all relevant MIBs: yes
Rebuild MIBs regardless of age: no
Dry run mode: no
Create/update MIBs: yes
Byte-compile Python modules: yes (optimization level no)
Ignore compilation errors: no
Generate OID->MIB index: no
Generate texts in MIBs: no
Keep original texts layout: no
Try various file names while searching for MIB module: yes
Created/updated MIBs:
Pre-compiled MIBs borrowed:
Up to date MIBs:
Missing source MIBs: MAV3-MIB
Ignored MIBs:
Failed MIBs:

Could you please help understanding why the MIB appears as missing ?

Thanks F

etingof commented 5 years ago

Sorry for the late answer!

I believe you should use the --mib-source= option to point mibdump to the directory where you have your MIB. Perhaps something like --mib-source=file:///sandbox though you may need to experiment with the URI syntax on Windows.

mr-sven commented 5 years ago

Hi, I faced the same problem on Windows. It is caused by urlparse.urlparse in file pysmi/reader/url.py urlparse result for file scheme in windows is leaving a slash at the beginning. Take a look at the following thread at stowfl: https://stackoverflow.com/questions/43911052/urlparse-on-a-windows-file-scheme-uri-leaves-extra-slash-at-start

etingof commented 5 years ago

@mr-sven Thanks! If you could push a PR working this around, I'd happily merge it. Otherwise I will address this a bit later.

etingof commented 5 years ago

@mr-sven I just added the same thing for Py2 and cherry-picked the entire patch chain to the older branch (0.3.5). Let me know if you need a release.

Thank you and sorry for sluggish responses!