Python Forum

Full Version: Warning / Error handling in python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am using netmiko on my ubuntu 12.04 to SSH into one of my router. I am able to successfully SSH into the router, however along with my output I get below warning/error -

john@lab:~$ sudo python t3.py
/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/constant_time.py:26: CryptographyDeprecationWarning: Support for your Python version is deprecated. The next version of cryptography will remove support. Please upgrade to a 2.7.x release that supports hmac.compare_digest as soon as possible.
utils.DeprecatedIn23,

Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES manual administratively down down
FastEthernet1/0 198.51.100.5 YES manual up up

I know that I have to update to new Linux OS version, however, can someone help me on how I can just store this warning/error and not let it interfere with my output.

I did try using the warning module, but no luck-

with warnings.catch_warnings():
warnings.simplefilter("ignore")
warnings.warn("deprecated", DeprecationWarning)
Try.
import warnings

warnings.filterwarnings('ignore')
import cryptography
from cryptography import utils

with warnings.catch_warnings():
    warnings.simplefilter('ignore', cryptography.utils.DeprecatedIn23)
    import cryptography.hazmat.primitives.constant_time
Another way can be to downgrade to a version before Waring was put in.
pip install cryptography==2.0.2