I am using Paramiko in my python code (for sftp). Everything works fine except that everytime I import or call a paramiko function. This warning would show up:
C
The most flexible way is to combine warnings.filterwarnings() with the warnings.catch_warnings() context manager. This way you ge the flexibility of filterwarnings
but the filtering is only applied inside the with
block:
import warnings
from Crypto.pct_warnings import RandomPool_DeprecationWarning
with warnings.catch_warnings():
warnings.filterwarnings(
action='ignore',
category=RandomPool_DeprecationWarning,
message='This application uses RandomPool, which is BROKEN in older releases')
# Do stuff that causes the warning