Commit 3492fef3 authored by Ibrahim Ahmed's avatar Ibrahim Ahmed
Browse files

Changed authentication exception to when login response parsing fails. Version bump to v0.2.6.

parent 1e9d8eda
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ Functions for obtaining data from various sources.



from json.decoder import JSONDecodeError
from typing import List, Dict, Any
from datetime import datetime
from urllib.parse import urlencode
@@ -75,11 +76,15 @@ def get_trend(trend_id: str, username: str, password: str, start: datetime,
    res_auth = sess.post(authURL, data=urlencode(payload),
                         headers={'Content-Type': 'application/x-www-form-urlencoded'})
    key = res_auth.cookies.get('IS_SSO')
    if key is None:
        raise Exception('Authentication failed.')
    print('KEY', key)
    # if key is None:
    #     raise Exception('Authentication failed.')

    res_trend_info = sess.get(trendinfoURL)
    try:
        trend_info = json.loads(res_trend_info.content)
    except JSONDecodeError as e:
        raise ValueError('Authentication failed - could not parse login result.') from e

    payload = {
        'selectorList': trend_info['values'],
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ from distutils.core import setup


setup(name='bdx',
      version='0.2.5',
      version='0.2.6',
      description='Download trends from Building Logix data exchange (BDX)',
      author='Ibrahim Ahmed',
      author_email='ibrahim.ahmed@vanderbilt.edu',