Skip to content

Commit

Permalink
use latest version of black
Browse files Browse the repository at this point in the history
  • Loading branch information
glaslos committed Mar 4, 2024
1 parent 24bacee commit 5a55d26
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 29 deletions.
11 changes: 7 additions & 4 deletions bin/conpot
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ def main():
default=False,
)
parser.add_argument(
"-c", "--config", help="The configuration file to use", metavar="conpot.cfg",
"-c",
"--config",
help="The configuration file to use",
metavar="conpot.cfg",
)

parser.add_argument(
Expand Down Expand Up @@ -256,9 +259,9 @@ def main():
package_directory, "templates", folder, "template.xml"
)
if os.path.isfile(template_xml):
template_unit = (
template_vendor
) = template_description = template_protocols = template_creator = "N/A"
template_unit = template_vendor = template_description = (
template_protocols
) = template_creator = "N/A"
dom_template = etree.parse(template_xml)
template_details = dom_template.xpath("//core/template/*")
if template_details:
Expand Down
30 changes: 15 additions & 15 deletions conpot/core/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ def setinfo(self, path, info):
self._cache[path].raw["access"]["permissions"] = access[
"permissions"
]
self._cache[path].raw["details"][
"metadata_changed"
] = fs.time.datetime_to_epoch(datetime.now())
self._cache[path].raw["details"]["metadata_changed"] = (
fs.time.datetime_to_epoch(datetime.now())
)
if "user" in access or "uid" in access:
try:
if "user" in access or (
Expand All @@ -290,19 +290,19 @@ def setinfo(self, path, info):
if value == {"user": access["user"]}
]
self._cache[path].raw["access"]["uid"] = _uid
self._cache[path].raw["details"][
"metadata_changed"
] = fs.time.datetime_to_epoch(datetime.now())
self._cache[path].raw["details"]["metadata_changed"] = (
fs.time.datetime_to_epoch(datetime.now())
)
else:
# Must be 'uid' that is available.
_uid = int(access["uid"]) # type: ignore
self._cache[path].raw["access"]["uid"] = _uid
self._cache[path].raw["access"]["user"] = self._users[
_uid
]["user"]
self._cache[path].raw["details"][
"metadata_changed"
] = fs.time.datetime_to_epoch(datetime.now())
self._cache[path].raw["details"]["metadata_changed"] = (
fs.time.datetime_to_epoch(datetime.now())
)
except (TypeError, AssertionError, KeyError):
raise
if "group" in access or "gid" in access:
Expand All @@ -319,19 +319,19 @@ def setinfo(self, path, info):
if value == {"group": access["group"]}
]
self._cache[path].raw["access"]["gid"] = _gid
self._cache[path].raw["details"][
"metadata_changed"
] = fs.time.datetime_to_epoch(datetime.now())
self._cache[path].raw["details"]["metadata_changed"] = (
fs.time.datetime_to_epoch(datetime.now())
)
else:
# Must be 'gid' that is available.
_gid = int(access["gid"]) # type: ignore
self._cache[path].raw["access"]["gid"] = _gid
self._cache[path].raw["access"]["group"] = self._grps[
_gid
]["group"]
self._cache[path].raw["details"][
"metadata_changed"
] = fs.time.datetime_to_epoch(datetime.now())
self._cache[path].raw["details"]["metadata_changed"] = (
fs.time.datetime_to_epoch(datetime.now())
)
except (TypeError, AssertionError, KeyError):
raise
else:
Expand Down
2 changes: 0 additions & 2 deletions conpot/protocols/IEC104/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@


class InvalidFieldValueException(ValueError):

"""This error is raised if a field value is not allowed"""

def __init__(self, *args):
self.args = args


class FrameError(Exception):

"""This error is raised if the IEC104 frame is wrong or ain't a IEC104 packet at all"""

def __init__(self, *args):
Expand Down
1 change: 0 additions & 1 deletion conpot/protocols/modbus/slave.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


class MBSlave(Slave):

"""
Customized Modbus slave representation extending modbus_tk.modbus.Slave
"""
Expand Down
1 change: 0 additions & 1 deletion conpot/protocols/modbus/slave_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


class SlaveBase(Databank):

"""
Database keeping track of the slaves.
"""
Expand Down
8 changes: 4 additions & 4 deletions conpot/protocols/snmp/command_responder.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ def register(self, mibname, symbolname, instance, value, profile_map_name):
if s:
self.oid_mapping[s.name + instance] = profile_map_name

(
MibScalarInstance,
) = self.snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols(
"SNMPv2-SMI", "MibScalarInstance"
(MibScalarInstance,) = (
self.snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols(
"SNMPv2-SMI", "MibScalarInstance"
)
)
x = MibScalarInstance(s.name, instance, s.syntax.clone(value))
self.snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.exportSymbols(
Expand Down
1 change: 0 additions & 1 deletion conpot/tests/test_bacnet_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@


class TestBACnetServer(unittest.TestCase):

"""
All tests are executed in a similar way. We initiate a service request to the BACnet server and wait for response.
Instead of decoding the response, we create an expected response. We encode the expected response and compare the
Expand Down
1 change: 0 additions & 1 deletion conpot/tests/test_ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@


class TestFTPServer(unittest.TestCase):

"""
All tests are executed in a similar way. We run a valid/invalid FTP request/command and check for valid
response. Testing is done by sending/receiving files in data channel related commands.
Expand Down

0 comments on commit 5a55d26

Please sign in to comment.