Skip to content

Commit

Permalink
Merge branch 'dev' into bug#1450
Browse files Browse the repository at this point in the history
  • Loading branch information
seladb authored Sep 25, 2024
2 parents 4220df7 + bd7884b commit 1671b7d
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 26 deletions.
10 changes: 7 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ repos:
- id: mixed-line-ending
args: ['--fix=lf']
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 24.8.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.5
hooks:
- id: black
- id: ruff # Run the linter.
types_or: [ python ]
- id: ruff-format # Run the formatter.
types_or: [ python ]
args: [ --check ]
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
Expand Down
2 changes: 1 addition & 1 deletion 3rdParty/OUIDataset/create_oui_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def convert_line(line: str) -> list[str]:


def parse_mac_and_vendor(line_parts: list[str]) -> Optional[LineElements]:
if line_parts == None or len(line_parts) < 3:
if line_parts is None or len(line_parts) < 3:
return None

if len(line_parts[0]) == 6:
Expand Down
1 change: 0 additions & 1 deletion Tests/ExamplesTest/tests/test_httpanalyzer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from os import path
from itertools import filterfalse
import pytest
from .test_utils import ExampleTest, compare_stdout_with_file

Expand Down
6 changes: 2 additions & 4 deletions Tests/ExamplesTest/tests/test_pcapsearch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from os import path
import pytest
import re
import ntpath
from .test_utils import ExampleTest

Expand Down Expand Up @@ -42,7 +40,7 @@ def test_exact_file_format(self):
num_of_packets = int(words[0])
file_name = ntpath.basename(words[-1].replace("'", ""))
actual.add((num_of_packets, file_name))
except:
except Exception:
pass

assert expected.issubset(actual)
Expand All @@ -52,7 +50,7 @@ def test_different_file_extensions(self):
completed_process = self.run_example(args=args)
assert ".dmp'" in completed_process.stdout
assert ".pcapng'" in completed_process.stdout
assert not ".pcap'" in completed_process.stdout
assert ".pcap'" not in completed_process.stdout

def test_no_args(self):
args = {}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ExamplesTest/tests/test_pcapsplitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def test_split_by_connection(self, tmpdir):
else:
conn = frozenset([])

assert not conn in connection_map
assert conn not in connection_map
connection_map[conn] = True

if len(conn) == 0:
Expand Down
1 change: 0 additions & 1 deletion Tests/ExamplesTest/tests/test_sslanalyzer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from os import path
from itertools import filterfalse
import pytest
from .test_utils import ExampleTest, compare_stdout_with_file

Expand Down
1 change: 0 additions & 1 deletion Tests/ExamplesTest/tests/test_tlsfingerprinting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import filecmp
import pytest
from .test_utils import (
ExampleTest,
Expand Down
2 changes: 1 addition & 1 deletion ci/run_tests/run_tests_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def find_interface():
if completed_process.returncode != 0:
continue
return interface, ip_address
except:
except Exception:
pass
return None, None

Expand Down
24 changes: 11 additions & 13 deletions cmake/setup_dpdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ def usage():
[Restore]
sudo python setup_dpdk.py restore\n\n
""".format(
settings_file=_SETTINGS_FILE
)
""".format(settings_file=_SETTINGS_FILE)


# This is roughly compatible with check_output function in subprocess module
Expand Down Expand Up @@ -439,7 +437,7 @@ def handle_error(error_msg):
filename = "/sys/bus/pci/drivers/%s/unbind" % dev["Driver_str"]
try:
file_d = open(filename, "a")
except: # pylint:disable=bare-except
except Exception:
handle_error(
"Error: unbind failed for %s - Cannot open %s" % (dev_id, filename)
)
Expand Down Expand Up @@ -491,7 +489,7 @@ def handle_error(error_msg):
if os.path.exists(filename):
try:
file_d = open(filename, "w")
except: # pylint:disable=bare-except
except Exception:
handle_error(
"Error: bind failed for %s - Cannot open %s" % (dev_id, filename)
)
Expand All @@ -500,7 +498,7 @@ def handle_error(error_msg):
file_d.write("%s" % driver)
logger.debug("bind_one: write '%s' to '%s'", driver, filename)
file_d.close()
except: # pylint:disable=bare-except
except Exception:
handle_error(
"Error: bind failed for %s - Cannot write driver %s to "
"PCI ID " % (dev_id, driver)
Expand All @@ -511,7 +509,7 @@ def handle_error(error_msg):
filename = "/sys/bus/pci/drivers/%s/new_id" % driver
try:
file_d = open(filename, "w")
except: # pylint:disable=bare-except
except Exception:
handle_error(
"Error: bind failed for %s - Cannot open %s" % (dev_id, filename)
)
Expand All @@ -520,7 +518,7 @@ def handle_error(error_msg):
# Convert Device and Vendor Id to int to write to new_id
file_d.write("%04x %04x" % (int(dev["Vendor"], 16), int(dev["Device"], 16)))
file_d.close()
except: # pylint:disable=bare-except
except Exception:
handle_error(
"Error: bind failed for %s - Cannot write new PCI ID to "
"driver %s" % (dev_id, driver)
Expand All @@ -531,7 +529,7 @@ def handle_error(error_msg):
filename = "/sys/bus/pci/drivers/%s/bind" % driver
try:
file_d = open(filename, "a")
except: # pylint:disable=bare-except
except Exception:
logger.error("Error: bind failed for %s - Cannot open %s", dev_id, filename)
if saved_driver is not None: # restore any previous driver
bind_one(dev_id, saved_driver, quiet, force)
Expand All @@ -540,7 +538,7 @@ def handle_error(error_msg):
file_d.write(dev_id)
logger.debug("bind_one: write '%s' to '%s'", dev_id, filename)
file_d.close()
except: # pylint:disable=bare-except
except Exception:
# for some reason, closing dev_id after adding a new PCI ID to new_id
# results in IOError. however, if the device was successfully bound,
# we don't care for any errors and can safely ignore IOError
Expand All @@ -561,7 +559,7 @@ def handle_error(error_msg):
if os.path.exists(filename):
try:
file_d = open(filename, "w")
except: # pylint:disable=bare-except
except Exception:
handle_error(
"Error: unbind failed for %s - Cannot open %s" % (dev_id, filename)
)
Expand All @@ -570,7 +568,7 @@ def handle_error(error_msg):
file_d.write("\00")
logger.debug("bind_one: write '\00' to '%s'", filename)
file_d.close()
except: # pylint:disable=bare-except
except Exception:
handle_error(
"Error: unbind failed for %s - Cannot open %s" % (dev_id, filename)
)
Expand Down Expand Up @@ -1216,7 +1214,7 @@ def main():
try:
args.func(args, settings)
settings.save(settings_file_full_path)
except: # pylint:disable=bare-except
except Exception:
pass


Expand Down

0 comments on commit 1671b7d

Please sign in to comment.