#!/usr/bin/env python2

from __future__ import print_function

import sys
import os.path

from urllib2 import urlopen

INVLIST_URL = 'http://dev.tsadm.local:8000/asb/inv/lst/'
SSL_CERT_FILE = os.path.expanduser('.asbot.pem')

ssl_context = None
if INVLIST_URL.startswith('https:'):
    try:
        import ssl
        ssl_context = ssl.create_default_context()
        ssl_context.check_hostname = False
        ssl_context.verify_mode = ssl.CERT_NONE
        ssl_context.load_cert_chain(SSL_CERT_FILE)
    except Exception as e:
        print(INVLIST_URL, str(e))

if len(sys.argv) >= 2 and sys.argv[1] == '--list':
    try:
        print(urlopen(INVLIST_URL, timeout=15, context=ssl_context).read())
    except Exception as e:
        print(INVLIST_URL, str(e))
else:
    print('{}')

sys.exit(0)

#!/usr/bin/env python2

from __future__ import print_function

import sys
import os.path

from urllib2 import urlopen

INVLIST_URL = 'http://dev.tsadm.local:8000/asb/inv/lst/'
SSL_CERT_FILE = os.path.expanduser('~/.asbot.pem')

ssl_context = None
if INVLIST_URL.startswith('https:'):
    try:
        import ssl
        ssl_context = ssl.create_default_context()
        ssl_context.check_hostname = False
        ssl_context.verify_mode = ssl.CERT_NONE
        ssl_context.load_cert_chain(SSL_CERT_FILE)
    except Exception as e:
        print(INVLIST_URL, str(e))

if len(sys.argv) >= 2 and sys.argv[1] == '--list':
    try:
        print(urlopen(INVLIST_URL, timeout=15, context=ssl_context).read())
    except Exception as e:
        print(INVLIST_URL, str(e))
else:
    print('{}')

sys.exit(0)

fix asb bot pem path