Skip to content

Commit

Permalink
Remove unused error variables
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Sep 25, 2024
1 parent 5d6feef commit c58d68e
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion python/nav/bin/macwatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def post_event(mac_watch, cam):
event['alerttype'] = 'macWarning'
try:
event.post()
except Exception as why:
except Exception:
_logger.exception("Unhandled exception while posting event")
return False
return True
Expand Down
2 changes: 1 addition & 1 deletion python/nav/bin/radiusparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def main(args=None):
# Check if the line is parseable
try:
row = Row(parse_line(line))
except AttributeError as e:
except AttributeError:
print("AttributeError: " + line)

# We want to look for octals in the messages
Expand Down
4 changes: 2 additions & 2 deletions python/nav/bin/snmptrapd.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def main():
server.listen(opts.community, trap_handler)
except SystemExit:
raise
except Exception as why:
except Exception:
_logger.critical("Fatal exception ocurred", exc_info=True)

else:
Expand All @@ -154,7 +154,7 @@ def main():
try:
_logger.info("Listening on %s", addresses_text)
server.listen(opts.community, trap_handler)
except KeyboardInterrupt as why:
except KeyboardInterrupt:
_logger.error("Received keyboard interrupt, exiting.")
server.close()

Expand Down
2 changes: 1 addition & 1 deletion python/nav/eventengine/severity.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _parse_rule_sublist(
if attr == "severity":
try:
modifier = cls._parse_modifier(value)
except ValueError as error:
except ValueError:
raise ValueError(
f"{value!r} is an invalid severity modifier expression"
) from None
Expand Down
2 changes: 1 addition & 1 deletion python/nav/eventengine/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def get_source_address_for(dest):
sock = socket.socket(family, socket.SOCK_DGRAM)
try:
sock.connect(sockaddr)
except socket.error as err:
except socket.error:
_logger.warning(
"Error when getting NAV's source address for "
"connecting to %(dest)s: %(err)s",
Expand Down
2 changes: 1 addition & 1 deletion python/nav/portadmin/snmp/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def test_read(self):
try:
handle.get(self.SYSOBJECTID)
return True
except SnmpError as error:
except SnmpError:
return False

def test_write(self):
Expand Down
8 changes: 4 additions & 4 deletions python/nav/portadmin/snmp/cisco.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def set_cisco_voice_vlan(self, interface, voice_vlan):
)
except SnmpError as error:
_logger.error('Error setting voice vlan: %s', error)
except ValueError as error:
except ValueError:
_logger.error('%s is not a valid voice vlan', voice_vlan)
raise

Expand All @@ -159,7 +159,7 @@ def enable_cisco_cdp(self, interface):
"""Enable CDP using Cisco specific oid"""
try:
return self._set_netbox_value(self.cdp_oid, interface.ifindex, 'i', 1)
except ValueError as error:
except ValueError:
_logger.error('%s is not a valid option for cdp', 1)
raise

Expand All @@ -173,7 +173,7 @@ def disable_cisco_cdp(self, interface):
"""Disable CDP using Cisco specific oid"""
try:
return self._set_netbox_value(self.cdp_oid, interface.ifindex, 'i', 2)
except ValueError as error:
except ValueError:
_logger.error('%s is not a valid option for cdp', 2)
raise

Expand Down Expand Up @@ -339,7 +339,7 @@ def set_poe_state(self, interface: manage.Interface, state: PoeState):
except SnmpError as error:
_logger.error('Error setting poe state: %s', error)
raise
except ValueError as error:
except ValueError:
_logger.error('%s is not a valid option for poe state', state)
raise

Expand Down
2 changes: 1 addition & 1 deletion python/nav/smsd/gammudispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

try:
import gammu
except ImportError as error:
except ImportError:
raise PermanentDispatcherError('python-gammu not installed or misconfigured.')


Expand Down
2 changes: 1 addition & 1 deletion python/nav/statemon/checker/MysqlChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def execute(self):
conn.write_auth_packet('navmon')
try:
conn.read_packet()
except MysqlError as err:
except MysqlError:
pass # Ignore login error

return Event.UP, 'OK'
Expand Down
2 changes: 1 addition & 1 deletion python/nav/statemon/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def cursor(self):
err.pgcode,
)
raise
except Exception as err:
except Exception:
if self.db is not None:
_logger.critical(
"Could not get cursor. Trying to reconnect...", exc_info=True
Expand Down

0 comments on commit c58d68e

Please sign in to comment.