compatibility to python 3.6 ...

pull/1/head
Steve L. Nyemba 5 years ago
parent 92d4e952e1
commit d0a0334f7a

@ -45,12 +45,24 @@ __author__ = 'The Phi Technology'
import numpy as np import numpy as np
import json import json
import importlib import importlib
from common import Reader, Writer #, factory import sys
import disk
import queue if sys.version_info[0] > 2 :
import couch from transport.common import Reader, Writer #, factory
import mongo from transport import disk
import s3 from transport import queue as queue
from transport import couch as couch
from transport import mongo as mongo
from transport import s3 as s3
else:
from common import Reader, Writer #, factory
import disk
import queue
import couch
import mongo
import s3
class factory : class factory :
@staticmethod @staticmethod
def instance(**args): def instance(**args):
@ -78,7 +90,7 @@ class factory :
try: try:
anObject = eval( aClassName) anObject = eval( aClassName)
#setattr(anObject,'name',source) #setattr(anObject,'name',source)
except Exception,e: except Exception as e:
print ['Error ',e] print ['Error ',e]
return anObject return anObject
@ -207,4 +219,4 @@ class factory :
# #setattr(anObject,'name',source) # #setattr(anObject,'name',source)
# except Exception,e: # except Exception,e:
# print ['Error ',e] # print ['Error ',e]
# return anObject # return anObject

@ -7,7 +7,11 @@ This file is a wrapper around couchdb using IBM Cloudant SDK that has an interfa
""" """
import cloudant import cloudant
import json import json
from common import Reader,Writer import sys
if sys.version_info[0] > 2 :
from transport.common import Reader, Writer
else:
from common import Reader, Writer
class Couch: class Couch:
""" """
This class is a wrapper for read/write against couchdb. The class captures common operations for read/write. This class is a wrapper for read/write against couchdb. The class captures common operations for read/write.

@ -6,7 +6,11 @@ This file is a wrapper around mongodb for reading/writing content against a mong
""" """
from pymongo import MongoClient from pymongo import MongoClient
# from transport import Reader,Writer # from transport import Reader,Writer
from common import Reader, Writer import sys
if sys.version_info[0] > 2 :
from transport.common import Reader, Writer
else:
from common import Reader, Writer
import json import json
class Mongo : class Mongo :
""" """

@ -10,7 +10,11 @@ from datetime import datetime
import re import re
import json import json
import os import os
from common import Reader, Writer import sys
if sys.version_info[0] > 2 :
from transport.common import Reader, Writer
else:
from common import Reader, Writer
import json import json
class MessageQueue: class MessageQueue:
@ -31,9 +35,9 @@ class MessageQueue:
self.close() self.close()
return resp return resp
def close(self): def close(self):
if self.connection.is_closed == False : if self.connection.is_closed == False :
self.channel.close() self.channel.close()
self.connection.close() self.connection.close()
class QueueWriter(MessageQueue,Writer): class QueueWriter(MessageQueue,Writer):
""" """
@ -204,4 +208,4 @@ class QueueListener(QueueReader):
self.init(self.qid) self.init(self.qid)
self.channel.basic_consume(self.callback,queue=self.qid,no_ack=True); self.channel.basic_consume(self.callback,queue=self.qid,no_ack=True);
self.channel.start_consuming() self.channel.start_consuming()

@ -8,9 +8,13 @@ from datetime import datetime
import boto import boto
import botocore import botocore
from smart_open import smart_open from smart_open import smart_open
from common import Reader, Writer import sys
if sys.version_info[0] > 2 :
from transport.common import Reader, Writer
else:
from common import Reader, Writer
import json import json
from common import Reader, Writer
class s3 : class s3 :
""" """

Loading…
Cancel
Save