# HG changeset patch # User Ioannis # Date 1536074090 -10800 # Node ID 9d25bd3e15c40b69803e119309a299c78462ce57 # Parent ddaea4327bd5068344a56b801bb11b666edb38c7 Some 2to3 changes. diff -r ddaea4327bd5 -r 9d25bd3e15c4 requirements.txt --- a/requirements.txt Wed Jan 10 18:06:02 2018 +0200 +++ b/requirements.txt Tue Sep 04 18:14:50 2018 +0300 @@ -1,1 +1,1 @@ -requests +. \ No newline at end of file diff -r ddaea4327bd5 -r 9d25bd3e15c4 scc_access/scc_access.py --- a/scc_access/scc_access.py Wed Jan 10 18:06:02 2018 +0200 +++ b/scc_access/scc_access.py Tue Sep 04 18:14:50 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