Skip to content

Commit

Permalink
Merge pull request #3028 from Uninett/cleanup/remove-unused-error-var…
Browse files Browse the repository at this point in the history
…iables

Remove unused error variables
  • Loading branch information
johannaengland authored Nov 22, 2024
2 parents 518b252 + 09c4d7e commit c61be8e
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion python/nav/bin/macwatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,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 @@ -144,7 +144,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 @@ -153,7 +153,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
6 changes: 3 additions & 3 deletions python/nav/eventengine/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ def get_source_address_for(dest):
sock.connect(sockaddr)
except socket.error as err:
_logger.warning(
"Error when getting NAV's source address for "
"connecting to %(dest)s: %(err)s",
locals(),
"Error when getting NAV's source address for connecting to %s: %s",
dest,
err,
)
return
addrinfo = sock.getsockname()
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 c61be8e

Please sign in to comment.