Merging pull request for rs uploading

Thu, 11 Oct 2018 13:14:33 +0300

author
Iannis <i.binietoglou@impworks.gr>
date
Thu, 11 Oct 2018 13:14:33 +0300
changeset 28
2d90204710af
parent 27
8ebbba085eb0 (diff)
parent 26
0aedb8dd6861 (current diff)
child 30
4669876326d4

Merging pull request for rs uploading

.hgignore file | annotate | diff | comparison | revisions
scc_access/scc_access.py file | annotate | diff | comparison | revisions
--- 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
--- 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
--- 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

mercurial