# HG changeset patch # User Iannis # Date 1539249348 -10800 # Node ID 2a6a9e95bd1600b3bb11269c3c4459126a8f47ca # Parent 9d25bd3e15c40b69803e119309a299c78462ce57# Parent a952c1b250a87553514416d22f73516f1143fae2 Merge. diff -r a952c1b250a8 -r 2a6a9e95bd16 requirements.txt --- a/requirements.txt Thu Oct 11 12:11:52 2018 +0300 +++ b/requirements.txt Thu Oct 11 12:15:48 2018 +0300 @@ -1,1 +1,1 @@ -requests +. \ No newline at end of file diff -r a952c1b250a8 -r 2a6a9e95bd16 scc_access/scc_access.py --- a/scc_access/scc_access.py Thu Oct 11 12:11:52 2018 +0300 +++ b/scc_access/scc_access.py Thu Oct 11 12:15:48 2018 +0300 @@ -2,12 +2,17 @@ requests.packages.urllib3.disable_warnings() import sys -import urlparse + +try: + import urllib.parse as urlparse # Python 3 +except ImportError: + import urlparse # Python 2 + import argparse import os import re import time -import StringIO +from io import StringIO from zipfile import ZipFile import datetime import logging @@ -128,7 +133,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 @@ -366,7 +371,7 @@ return measurement_id -class ApiObject: +class ApiObject(object): """ A generic class object. """ def __init__(self, base_url, dict_response): @@ -375,7 +380,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