# HG changeset patch # User Iannis # Date 1539252873 -10800 # Node ID 2d90204710af93d356605266c097349ec8ac448f # Parent 8ebbba085eb0e57b50585758fa108b13559cbab2# Parent 0aedb8dd6861d499110e35cf9390f1277d92a4f9 Merging pull request for rs uploading diff -r 0aedb8dd6861 -r 2d90204710af .hgignore --- a/.hgignore Thu Oct 04 11:37:15 2018 +0200 +++ b/.hgignore Thu Oct 11 13:14:33 2018 +0300 @@ -1,7 +1,8 @@ -syntax: glob -*.rst~ -*.py~ -*.pyc -re:^settings\.py$ -re:^\.idea/ -re:^\.pytest_cache/ +syntax: glob +*.rst~ +*.py~ +*.pyc +re:^settings\.py$ +re:^\.idea/ +scc_access.egg-info/ +re:^\.pytest_cache/ \ No newline at end of file diff -r 0aedb8dd6861 -r 2d90204710af requirements.txt --- a/requirements.txt Thu Oct 04 11:37:15 2018 +0200 +++ b/requirements.txt Thu Oct 11 13:14:33 2018 +0300 @@ -1,1 +1,1 @@ -requests +. \ No newline at end of file diff -r 0aedb8dd6861 -r 2d90204710af scc_access/scc_access.py --- a/scc_access/scc_access.py Thu Oct 04 11:37:15 2018 +0200 +++ b/scc_access/scc_access.py Thu Oct 11 13:14:33 2018 +0300 @@ -1,9 +1,19 @@ +import requests +requests.packages.urllib3.disable_warnings() + +import sys + +try: + import urllib.parse as urlparse # Python 3 +except ImportError: + import urlparse # Python 2 + import argparse import datetime import logging import os import re -import StringIO +from io import StringIO import sys import time import urlparse @@ -131,7 +141,7 @@ os.makedirs(local_dir) # Save the file by chunk, needed if the file is big. - memory_file = StringIO.StringIO() + memory_file = StringIO() for chunk in request.iter_content(chunk_size=1024): if chunk: # filter out keep-alive new chunks @@ -395,7 +405,7 @@ return measurement_id -class ApiObject: +class ApiObject(object): """ A generic class object. """ def __init__(self, base_url, dict_response): @@ -404,7 +414,11 @@ if dict_response: # Add the dictionary key value pairs as object properties for key, value in dict_response.items(): - setattr(self, key, value) + # logger.debug('Setting key {0} to value {1}'.format(key, value)) + try: + setattr(self, key, value) + except: + logger.warning('Could not set attribute {0} to value {1}'.format(key, value)) self.exists = True else: self.exists = False