Warning / Error handling in python - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Warning / Error handling in python (/thread-15979.html) |
Warning / Error handling in python - Prarthana_12 - Feb-08-2019 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) RE: Warning / Error handling in python - snippsat - Feb-08-2019 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_timeAnother way can be to downgrade to a version before Waring was put in. pip install cryptography==2.0.2 |