def init_api(): """ This methods initializes the API but first checks for a CCTRL_API_URL environment variable and uses it if found. For Windows we also need to load ca_certs differently, because the httplib2 provided ones are not included due to py2exe. """ try: api_url = os.environ.pop('CCTRL_API_URL') except KeyError: pass else: cclib.API_URL = api_url dirname = os.path.dirname(__file__) while len(dirname) > 1: p = os.path.join(dirname, 'cacerts.txt') if os.path.exists(p): cclib.CA_CERTS = p break dirname = os.path.dirname(dirname) return cclib.API(token=read_tokenfile())
def init_api(): """ This methods initializes the API but first checks for a CCTRL_API_URL environment variable and uses it if found. For Windows we also need to load ca_certs differently, because the httplib2 provided ones are not included due to py2exe. """ api_url = os.environ.pop('CCTRL_API_URL', None) if api_url: cclib.DISABLE_SSL_CHECK = True if sys.platform == 'win32': cclib.CA_CERTS = os.path.join( os.path.dirname(os.path.abspath(__file__ )), "../../cacerts.txt") return cclib.API(token=read_tokenfile(), api_url=api_url)
def init_api(settings): """ This methods initializes the API but first checks for a CCTRL_API_URL environment variable and uses it if found. For Windows we also need to load ca_certs differently, because the httplib2 provided ones are not included due to py2exe. """ dirname = os.path.dirname(__file__) while len(dirname) > 1: p = os.path.join(dirname, 'cacerts.txt') if os.path.exists(p): cclib.CA_CERTS = p break dirname = os.path.dirname(dirname) return cclib.API(token=read_tokenfile(settings), url=settings.api_url, token_source_url=settings.token_source_url, register_addon_url=settings.register_addon_url, encode_email=settings.encode_email)