Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Added AttributeError Exception to __del__ function in NetworkDriver #268

Merged
merged 2 commits into from
Jul 1, 2017

Conversation

ipv6freely
Copy link
Contributor

This commit fixes Issue #267:
https://github.com/napalm-automation/napalm-base/issues/267

Adding an exception handler for AttributeError allows the script to complete.

@@ -68,6 +68,8 @@ def __del__(self):
try:
if self.is_alive()["is_alive"]:
self.close()
except AttributeError:
Copy link
Member

@dbarrosop dbarrosop Jul 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is triggered only when deleting the object I think it's actually safer to just capture all the exceptions. Would you mind replacing both except clauses with just one?

         try:
              if self.is_alive()["is_alive"]:
                  self.close()
         except Exception:
              pass

@ipv6freely
Copy link
Contributor Author

Yes I agree with you. I have modified that code.

@dbarrosop
Copy link
Member

Thanks!

@dbarrosop
Copy link
Member

dbarrosop commented Jul 1, 2017

Fixes #267

@dbarrosop dbarrosop merged commit e72c522 into napalm-automation:develop Jul 1, 2017
dbarrosop added a commit that referenced this pull request Jul 3, 2017
* Fix mac address format

* Documentation: Fix example mac addresses to be proper form

* Correctly check all keys comply (#266)

* Improve coverage of get_network_driver() (#263)

* Improve coverage of get_network_driver

* Revert import of napalm_logs for tests

* Driver prepending optional

* Test more branches in get_network_driver

* Added AttributeError Exception to __del__ function in NetworkDriver (#268)

* Added AttributeError Exception to __del__ function in NetworkDriver class

* Added AttributeError Exception to __del__ function in NetworkDriver

* Dumb driver (#269)

* Context manager propagates exceptions properly

* Implemented generic mock driver

* Add possibility to raise Exceptions on demand

* Mock cli commands individually

* Map junos' _rpc to cli

* Mocking configuration management methods

* Added tests for configuration methods

* Bump version to 0.24.2 (#270)
bewing added a commit to bewing/napalm-base that referenced this pull request Jul 18, 2017
…to tox

* 'develop' of github.com:napalm-automation/napalm-base:
  Bump version to 0.24.3 (napalm-automation#275)
  Validate string before evaluating (napalm-automation#274)
  Bump version to 0.24.2 (napalm-automation#270)
  Dumb driver (napalm-automation#269)
  Added AttributeError Exception to __del__ function in NetworkDriver (napalm-automation#268)
  Improve coverage of get_network_driver() (napalm-automation#263)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants