Commit Graph

18 Commits

Author SHA1 Message Date
Gerald Combs 4819716f14 Tools: Switch make-manuf.py URLs to HTTPS.
standards-oui.ieee.org is now served over HTTPS.
2022-09-05 17:55:33 +00:00
Jim Young 371f98aec4 make-manuf.py: Remove HTML double quote entities 2022-02-14 23:12:56 +00:00
Gerald Combs f9d0f35363 Tools: Fix a make-manuf error and some Pylint warnings. 2021-10-31 16:04:00 -07:00
Gerald Combs 99ef1b2643 make-manuf updates.
Strip A.S. and oü, similar to other business types. Strip forward
slashes as well, including A/S.

Change-Id: Icf436f8663dc9cddf220642913eea7a60285ebc1
2021-02-17 14:21:41 -08:00
Gerald Combs 894a70d079 Remove a bunch of duplicate manuf.tmpl entries.
Update make-manuf.py to print "Skipping duplicate IEEE ..." when the
organization names are the same. Remove duplicates by running

    tools/make-manuf.py | awk '/Skipping duplicate IEEE/ {printf "^%s\t\n", $1 }' > /tmp/duplicates.pat
    grep -v -f /tmp/duplicates.pat manuf.tmpl > manuf.tmpl.new ; mv manuf.tmpl.new manuf.tmpl
2021-01-01 10:27:35 +00:00
Gerald Combs 30c392f166 Tools+test: Call python3 explicitly.
PEP 394[1] says,

"In cases where the script is expected to be executed outside virtual
 environments, developers will need to be aware of the following
 discrepancies across platforms and installation methods:

  * Older Linux distributions will provide a python command that refers
    to Python 2, and will likely not provide a python2 command.

  * Some newer Linux distributions will provide a python command that
    refers to Python 3.

  * Some Linux distributions will not provide a python command at all by
    default, but will provide a python3 command by default."

Debian has forced the issue by choosing the third option[2]:

"NOTE: Debian testing (bullseye) has removed the "python" package and
 the '/usr/bin/python' symlink due to the deprecation of Python 2."

Switch our shebang from "#!/usr/bin/env python" to "#!/usr/bin/env
python3" in some places. Remove some 2/3 version checks if we know we're
running under Python 3. Remove the "coding: utf-8" in a bunch of places
since that's the default in Python 3.

[1]https://www.python.org/dev/peps/pep-0394/#for-python-script-publishers
[2]https://wiki.debian.org/Python
2020-11-05 06:46:35 +00:00
Jeff Widman 8d7ebc732e Fix issues discovered by common python linters
Fix some issues discovered by common python linters including:
* switch `None` comparisons to use `is` rather than `==`. Identity !=
equality, and I've spent 40+ hours before tracking down a subtle bug
caused by exactly this issue. Note that this may introduce a problem if
one of the scripts is depending on this behavior, in which case the
comparison should be changed to `True`/`False` rather than `None`.
* Use `except Exception:` as bare `except:` statements have been
discouraged for years. Ideally for some of these we'd examine if there
were specific exceptions that should be caught, but for now I simply
caught all. Again, this could introduce very subtle behavioral changes
under Python 2, but IIUC, that was all fixed in Python 3, so safe to
move to `except Exception:`.
* Use more idiomatic `if not x in y`--> `if x not in y`
* Use more idiomatic 2 blank lines. I only did this at the beginning,
until I realized how overwhelming this was going to be to apply, then I
stopped.
* Add a TODO where an undefined function name is called, so will fail
whenever that code is run.
* Add more idiomatic spacing around `:`. This is also only partially
cleaned up, as I gave up when I saw how `asn2wrs.py` was clearly
infatuated with the construct.
* Various other small cleanups, removed some trailing whitespace and
improper indentation that wasn't a multiple of 4, etc.

There is still _much_ to do, but I haven't been heavily involved with
this project before, so thought this was a sufficient amount to put up
and see what the feedback is.

Linters that I have enabled which highlighted some of these issues
include:
* `pylint`
* `flake8`
* `pycodestyle`
2020-09-26 04:38:18 +00:00
Gerald Combs 4d67f06108 make-manuf.py: Add "of" to the general terms list.
Add "of" to the list of general terms to remove when shortening.

Change-Id: Idbfea2d502a89d668ba2f170bf3450cfcbb91fe5
Reviewed-on: https://code.wireshark.org/review/35627
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2020-01-02 22:57:32 +00:00
Gerald Combs 12550ef794 make-manuf.py: Fix a shortening error.
Handle cases where we might shorten a name (e.g. "ZAO") down to
nothing.

Change-Id: I5ecb9592d2ecd8225d0ed459ef16885214af5da4
Reviewed-on: https://code.wireshark.org/review/35584
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2019-12-29 18:30:16 +00:00
Gerald Combs f8808b8bd0 make-manuf.py: Handle more business types and other fixes.
Move our business types and general terms to a list and add more. Only
convert all upper case names to title case. Remove double quotes when
shortening names.

Change-Id: I31e9799986542270350b8c2436929f293de4e36c
Reviewed-on: https://code.wireshark.org/review/35577
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2019-12-29 02:42:06 +00:00
Gerald Combs 6f57aa72a8 Make a couple of scripts Python 3 only.
Remove Python 2 support from tools/make-manuf.py and tools/make-usb.py.

Don't double-escape UTF-8 sequences in make-usb.py so that we generate

    { 0x045e000e, "SideWinder\xc2\xae Freestyle Pro" },

instead of

    { 0x045e000e, "SideWinder\\xc2\\xae Freestyle Pro" },

Change-Id: I918f854ccba868a122fd7b138c1654b2c7615f94
Reviewed-on: https://code.wireshark.org/review/32839
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2019-04-12 20:12:10 +00:00
Gerald Combs 6501231a3c make-manuf.py: Add response headers.
Add comments containing the resonse headers for the URLs we fetch.
standards-oui.ieee.org currently returns inconsistent results depending
on which host you happen to resolve.

Change-Id: I4adba7e51628d0350ba8e091523807ec85009700
Reviewed-on: https://code.wireshark.org/review/29729
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-09-19 00:34:50 +00:00
Gerald Combs 7b65208ef3 make-manuf.py: Add back our user agent.
Change-Id: I39c54fa38c791f3244075b03a0045babc4f249ec
Reviewed-on: https://code.wireshark.org/review/29706
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-09-17 18:30:27 +00:00
Gerald Combs 56a30766ef make-manuf.py: Improve truncation.
If the PyICU module is available, use it to truncate manufacturer
names by grapheme clusters.

Change-Id: Ib7dcbb126809df496a534f44a47871a1b28dc539
Reviewed-on: https://code.wireshark.org/review/29660
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-09-14 18:01:49 +00:00
Gerald Combs bc600962e2 Manuf fixups.
Remove some entries from manuf.tmpl that are either redundant or less
informative that their corresponding IEEE entries. Add a missing '"' to
make-manuf.py.

Change-Id: Ia69f4529c5fa1b39f1662b94d072c65bd2d969ea
Reviewed-on: https://code.wireshark.org/review/29568
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-09-10 17:38:03 +00:00
Gerald Combs cba7dfb40b make-manuf.py: Expand a comment.
Change-Id: I545a63bb4a045ba93d1ad1ee82315315bdbb3c9e
Reviewed-on: https://code.wireshark.org/review/29508
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-09-10 04:07:08 +00:00
Gerald Combs aba5c65f4d make-manuf.py: Skip the title row of each .csv file.
Change-Id: I88a4b3da6b75d4891dc3b3e5b8ceb1233e038932
Reviewed-on: https://code.wireshark.org/review/29470
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-09-07 17:23:53 +00:00
Gerald Combs a1fac65d8e Migrate make-manuf to Python+CSV.
The download links offered by the IEEE at
https://standards.ieee.org/products-services/regauth/ are CSV files.
Updating the Perl version to support CSV would have required rewriting a
significant portion of the script along with either adding a dependency
on Text::CSV or writing our own CSV parser.

Migrate it to Python, which has a built-in CSV module.

Change-Id: I39ba0ec873145f44374ab9f751e8bde51535ca4d
Reviewed-on: https://code.wireshark.org/review/29442
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-09-07 04:01:44 +00:00