From 3ca323bbf082f518f7658fc58fc664d787db7e24 Mon Sep 17 00:00:00 2001 From: Colter McQuay Date: Fri, 7 Apr 2017 15:26:03 -0700 Subject: [PATCH] Making compatible with python3 - updating print statemtents to use parenthesis --- pyONC/webservices/oncws.py | 42 +++++++++++++++++++------------------- setup.py | 3 +-- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/pyONC/webservices/oncws.py b/pyONC/webservices/oncws.py index c5c5158..4cad9f0 100644 --- a/pyONC/webservices/oncws.py +++ b/pyONC/webservices/oncws.py @@ -55,14 +55,14 @@ class ServiceMethod(object): """ def __init__(self, **kwargs): if verbose: - print "ServiceMethod.__init__" - print kwargs + print("ServiceMethod.__init__") + print(kwargs) self.decorator_kwargs = kwargs def __call__(self, f): if verbose: - print "ServiceMethod.__call__" - print f.__name__ + print("ServiceMethod.__call__") + print(f.__name__) @wraps(f) def wrapped_f(ServiceObj,**kwargs): @@ -92,8 +92,8 @@ def wrapped_f(ServiceObj,**kwargs): params['token'] = ServiceObj.token if verbose: - print URL - print params + print(URL) + print(params) if returnFormat == 'url': # Simply return the URL that would be called return URL + '?' + urllib.urlencode(params) @@ -101,16 +101,16 @@ def wrapped_f(ServiceObj,**kwargs): r=requests.get(URL, params=params) if not r.ok: try: - print '%d: %s' % (r.status_code, status_msgs[r.status_code]) + print('%d: %s' % (r.status_code, status_msgs[r.status_code])) except: - print '%d is not an expected status code...' % r.status_code + print('%d is not an expected status code...' % r.status_code) if verbose: - print r - print "%s.%s wrapped" % (ServiceObj.__class__, f.__name__) - print self.decorator_kwargs - print r.url - print ServiceObj.baseURL,ServiceObj.servicename, f.__name__,kwargs - print kwargs + print(r) + print("%s.%s wrapped" % (ServiceObj.__class__, f.__name__)) + print(self.decorator_kwargs) + print(r.url) + print(ServiceObj.baseURL,ServiceObj.servicename, f.__name__,kwargs) + print(kwargs) if returnFormat == 'json': #if (f.__name__=='getFile' and ServiceObj.servicename == 'archivefiles'): @@ -131,7 +131,7 @@ class _ExposedResource(object): """Abstract base object with common properties inheritet by webservice resources""" def __init__(self,baseURL=baseURL,token=None,returnFormat=None): if verbose: - print "Abstract init!!!" + print("Abstract init!!!") if returnFormat: self.returnFormat=returnFormat.lower() else: @@ -146,7 +146,7 @@ def __init__(self,baseURL=baseURL,token=None,returnFormat=None): def getToken(self): """If the user access token is unkown help user to find it""" #webbrowser('https://dmas.uvic.ca/Profile') - #print "Enter token:" + #print("Enter token:") self.token=token @@ -243,19 +243,19 @@ def printTree(self,showHidden="false"): nodeTree=self.getTree(showHidden=showHidden,returnFormat='json') for observatoryRoot in nodeTree: self._printNode(observatoryRoot) - print " " + print(" ") def _printNode(self,node,path=''): - #print "Node: ", node + #print("Node: ", node) for key in ['name', 'stationCode', 'description', 'deviceCategories', 'els']: if not node.has_key(key): - #print 'missing key: %s !!!!' % key + #print('missing key: %s !!!!' % key) node[key]=None path += '%s/' % node['name'] #deviceCategories=node['deviceCategories'].sort() - #print '%s\t%s\t%s\t%s' % (path, node['name'], node['stationCode'],', '.join(node['deviceCategories'])) + #print('%s\t%s\t%s\t%s' % (path, node['name'], node['stationCode'],', '.join(node['deviceCategories']))) #if 'JB' in node['deviceCategories']: - print path,', '.join(node['deviceCategories']) + print(path,', '.join(node['deviceCategories'])) childNodes=node['els'] #.sort(key='desciption') for childNode in childNodes: self._printNode(childNode,path=path) diff --git a/setup.py b/setup.py index 424419f..b122d16 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ from setuptools import setup #, find_packages setup(name='pyONC', - version='0.1.0', + version='0.1.1', description='Python tools for Ocean Networks Canada data access', url='https://github.com/MHee/pyONC', author='Martin Heesemann', @@ -16,4 +16,3 @@ license='MIT', packages=['pyONC','pyONC.webservices'], zip_safe=False) -#print find_packages() \ No newline at end of file