Python Forum
Warning / Error handling in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Warning / Error handling in python
#1
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)
Reply
#2
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Star python exception handling handling .... with traceback mg24 3 1,216 Nov-09-2022, 07:29 PM
Last Post: Gribouillis
  Help needed with a "for loop" + error handling tamiri 2 2,387 May-27-2022, 12:21 PM
Last Post: tamiri
  Handling pdf files with python. fuzzin 1 1,217 Jan-19-2022, 02:24 PM
Last Post: ThiefOfTime
  TicTacToe Game Add Exception Handling and Warning Function ShaikhShaikh 5 2,376 Nov-03-2021, 05:02 PM
Last Post: deanhystad
  Handling Python Fatal Error richajain1785 7 5,758 Oct-14-2021, 01:34 PM
Last Post: Tails86
  Handling multi-input/output audio in python bor1904 4 3,494 Nov-04-2020, 08:25 AM
Last Post: CHLOVRL
  Error Handling JarredAwesome 5 2,842 Oct-17-2020, 12:41 AM
Last Post: JarredAwesome
  Python Requests package: Handling xml response soumyarani 1 2,101 Sep-14-2020, 11:41 AM
Last Post: buran
  Handling Multiple USB ports in Python samalpramod 0 4,361 Aug-01-2020, 07:40 PM
Last Post: samalpramod
  Error handling using cmd module leifeng 3 2,801 Jun-06-2020, 06:25 PM
Last Post: leifeng

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020