2

How would I be able to selectively output certain python functions and not output others?

Code:

#!/usr/bin/env python

import os
import sys
import pprint

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

from m2x.client import M2XClient


KEY = '10e34b827d5e1cd90fds9d011006a7b4'
DEVICE_ID = '161add732eb725402d1182dafd74f907'

client = M2XClient(key=KEY)
device = client.device(DEVICE_ID)

cont = raw_input('Continue? [y/n] ')

if cont == 'y':
    print 'Continued...'
else:
    sys.exit()

Output:

/usr/local/lib/python2.7/dist-packages/requests-2.9.1-    py2.7.egg/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/requests-2.9.1-py2.7.egg/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Continue? [y/n]

Desired output to user:

Continue? [y/n]
  • @tmoreau That's a wrong duplicate. OP only wants to disable some specific module warnings, not all of them. – Lav Dec 23 '15 at 10:19

1 Answers1

3

If it's urllib3 library that's generating warnings, the best place to look would be it's documentation:

http://urllib3.readthedocs.org/en/latest/security.html#disabling-warnings

So:

import urllib3
urllib3.disable_warnings()

That said, suppressing warnings about HTTPS security might be a Very Bad Idea. :-)

Lav
  • 2,204
  • 12
  • 23