Skip to content

Commit

Permalink
linting: use specific exceptions where possible
Browse files Browse the repository at this point in the history
Signed-off-by: Bastian Stender <[email protected]>
  • Loading branch information
Bastian-Krause committed Jun 4, 2018
1 parent 533cec4 commit 8feb892
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/strategy/test_uboot_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def strategy(target):
try:
return target.get_driver('UBootStrategy')
except:
except NoDriverFoundError:
pytest.skip("strategy not found")


Expand Down
4 changes: 2 additions & 2 deletions labgrid/autoinstall/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def run(self):
self.context['target'] = self.target
if self.target is None:
raise KeyError
except:
except Exception: # pylint: disable=broad-except
self.log.exception("target creation failed")
return

Expand Down Expand Up @@ -123,7 +123,7 @@ def run_once(self):
next(iter(e.filter)))
else:
self.log.warning("resource not found, restarting")
except:
except Exception: # pylint: disable=broad-except
self.log.exception("handler failed")
return False

Expand Down
2 changes: 1 addition & 1 deletion labgrid/remote/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ def main():
exitcode = 1
except KeyboardInterrupt:
exitcode = 0
except:
except Exception: # pylint: disable=broad-except
traceback.print_exc()
exitcode = 2
exit(exitcode)
Expand Down
2 changes: 1 addition & 1 deletion labgrid/remote/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ async def poll(self):
await self._poll_step()
except asyncio.CancelledError:
break
except:
except Exception: # pylint: disable=broad-except
traceback.print_exc()

def save_later(self):
Expand Down
8 changes: 4 additions & 4 deletions labgrid/remote/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
try:
import pkg_resources
__version__ = pkg_resources.get_distribution('labgrid').version
except:
except pkg_resources.DistributionNotFound:
__version__ = "unknown"

def get_free_port():
Expand Down Expand Up @@ -351,7 +351,7 @@ async def onJoin(self, details):
group_name, resource_name, cls, params
)

except:
except Exception: # pylint: disable=broad-except
traceback.print_exc()
self.loop.stop()
return
Expand Down Expand Up @@ -400,7 +400,7 @@ async def _poll_step(self):
continue
try:
changed = resource.poll()
except:
except Exception: # pylint: disable=broad-except
print("Exception while polling {}".format(resource), file=sys.stderr)
traceback.print_exc()
continue
Expand All @@ -420,7 +420,7 @@ async def poll(self):
await self._poll_step()
except asyncio.CancelledError:
break
except:
except Exception: # pylint: disable=broad-except
traceback.print_exc()

async def add_resource(self, group_name, resource_name, cls, params):
Expand Down
2 changes: 1 addition & 1 deletion labgrid/resource/ethernetport.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ async def poll(self, handler):
await handler(self)
except asyncio.CancelledError:
break
except:
except Exception: # pylint: disable=broad-except
import traceback
traceback.print_exc()

Expand Down
2 changes: 1 addition & 1 deletion labgrid/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def notify(self, event):
for subscriber in self._subscribers:
try:
subscriber(event)
except Exception as e:
except Exception as e: # pylint: disable=broad-except
warnings.warn("unhandled exception during event notification: {}".format(e))

steps = Steps()
Expand Down
2 changes: 1 addition & 1 deletion labgrid/util/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def run(self):

try:
request = json.loads(line)
except:
except json.JSONDecodeError:
self._send({'error': 'request parsing failed'})
break

Expand Down

0 comments on commit 8feb892

Please sign in to comment.