Minor fixes. Raise exception when method is not implemented
Change-Id: I0080263c36959f24311c474d7241108f8c24bd48
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
diff --git a/osm_common/dbbase.py b/osm_common/dbbase.py
index aa9c24e..2dada76 100644
--- a/osm_common/dbbase.py
+++ b/osm_common/dbbase.py
@@ -6,6 +6,7 @@
class DbException(Exception):
def __init__(self, message, http_code=HTTPStatus.NOT_FOUND):
+ # TODO change to http.HTTPStatus instead of int that allows .value and .name
self.http_code = http_code
Exception.__init__(self, "database exception " + message)
@@ -22,16 +23,16 @@
pass
def get_list(self, table, filter={}):
- pass
+ raise DbException("Method 'get_list' not implemented")
def get_one(self, table, filter={}, fail_on_empty=True, fail_on_more=True):
- pass
+ raise DbException("Method 'get_one' not implemented")
def create(self, table, indata):
- pass
+ raise DbException("Method 'create' not implemented")
def del_list(self, table, filter={}):
- pass
+ raise DbException("Method 'del_list' not implemented")
def del_one(self, table, filter={}, fail_on_empty=True):
- pass
+ raise DbException("Method 'del_one' not implemented")
diff --git a/osm_common/fsbase.py b/osm_common/fsbase.py
index 60c0c0f..e975409 100644
--- a/osm_common/fsbase.py
+++ b/osm_common/fsbase.py
@@ -24,19 +24,19 @@
pass
def mkdir(self, folder):
- pass
+ raise FsException("Method 'mkdir' not implemented")
def file_exists(self, storage):
- pass
+ raise FsException("Method 'file_exists' not implemented")
def file_size(self, storage):
- pass
+ raise FsException("Method 'file_size' not implemented")
def file_extract(self, tar_object, path):
- pass
+ raise FsException("Method 'file_extract' not implemented")
def file_open(self, storage, mode):
- pass
+ raise FsException("Method 'file_open' not implemented")
def file_delete(self, storage, ignore_non_exist=False):
- pass
+ raise FsException("Method 'file_delete' not implemented")
diff --git a/osm_common/msgbase.py b/osm_common/msgbase.py
index a9d44d7..98f97bf 100644
--- a/osm_common/msgbase.py
+++ b/osm_common/msgbase.py
@@ -35,13 +35,13 @@
pass
def write(self, topic, key, msg):
- pass
+ raise MsgException("Method 'write' not implemented")
def read(self, topic):
- pass
+ raise MsgException("Method 'read' not implemented")
async def aiowrite(self, topic, key, msg, loop):
- pass
+ raise MsgException("Method 'aiowrite' not implemented")
async def aioread(self, topic, loop):
- pass
+ raise MsgException("Method 'aioread' not implemented")
diff --git a/osm_common/msgkafka.py b/osm_common/msgkafka.py
index 71e4948..382bdef 100644
--- a/osm_common/msgkafka.py
+++ b/osm_common/msgkafka.py
@@ -35,7 +35,8 @@
def disconnect(self):
try:
- self.loop.close()
+ pass
+ # self.loop.close()
except Exception as e: # TODO refine
raise MsgException(str(e))
diff --git a/osm_common/msglocal.py b/osm_common/msglocal.py
index 8fae7a2..75fc717 100644
--- a/osm_common/msglocal.py
+++ b/osm_common/msglocal.py
@@ -115,3 +115,14 @@
raise
except Exception as e: # TODO refine
raise MsgException(str(e))
+
+ async def aiowrite(self, topic, key, msg, loop=None):
+ """
+ Asyncio write. It blocks
+ :param topic: str
+ :param key: str
+ :param msg: message, can be str or yaml
+ :param loop: asyncio loop
+ :return: nothing if ok or raises an exception
+ """
+ return self.write(topic, key, msg)