merge commit conflicts
This commit is contained in:
parent
19d6588db6
commit
0a5379f7ab
|
@ -2,7 +2,6 @@
|
||||||
src/messagetypes/__init__.py
|
src/messagetypes/__init__.py
|
||||||
============================
|
============================
|
||||||
"""
|
"""
|
||||||
# pylint: disable=import-error
|
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from os import path, listdir
|
from os import path, listdir
|
||||||
from string import lower
|
from string import lower
|
||||||
|
@ -22,7 +21,7 @@ class MsgBase(object): # pylint: disable=too-few-public-methods
|
||||||
|
|
||||||
|
|
||||||
def constructObject(data):
|
def constructObject(data):
|
||||||
"""Construct an object"""
|
"""Constructing an object"""
|
||||||
whitelist = ["message"]
|
whitelist = ["message"]
|
||||||
if data[""] not in whitelist:
|
if data[""] not in whitelist:
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -9,26 +9,22 @@ from messagetypes import MsgBase
|
||||||
|
|
||||||
class Message(MsgBase):
|
class Message(MsgBase):
|
||||||
"""Base method, helps to decode, encode and process the message"""
|
"""Base method, helps to decode, encode and process the message"""
|
||||||
def __init__(self): # pylint: disable=super-init-not-called
|
|
||||||
return
|
|
||||||
|
|
||||||
def decode(self, data):
|
def decode(self, data):
|
||||||
"""Method used for decoding the message"""
|
"""Decode a message"""
|
||||||
# UTF-8 and variable type validator
|
# UTF-8 and variable type validator
|
||||||
# pylint: disable=unidiomatic-typecheck
|
if isinstance(data["subject"], str):
|
||||||
if type(data["subject"]) is str:
|
|
||||||
self.subject = unicode(data["subject"], 'utf-8', 'replace')
|
self.subject = unicode(data["subject"], 'utf-8', 'replace')
|
||||||
else:
|
else:
|
||||||
self.subject = unicode(str(data["subject"]), 'utf-8', 'replace')
|
self.subject = unicode(str(data["subject"]), 'utf-8', 'replace')
|
||||||
if type(data["body"]) is str:
|
if isinstance(data["body"], str):
|
||||||
self.body = unicode(data["body"], 'utf-8', 'replace')
|
self.body = unicode(data["body"], 'utf-8', 'replace')
|
||||||
else:
|
else:
|
||||||
self.body = unicode(str(data["body"]), 'utf-8', 'replace')
|
self.body = unicode(str(data["body"]), 'utf-8', 'replace')
|
||||||
|
|
||||||
def encode(self, data):
|
def encode(self, data):
|
||||||
"""Method used for encoding the message"""
|
"""Encode a message"""
|
||||||
# pylint: disable=no-member
|
super(Message, self).__init__()
|
||||||
super(Message, self).encode()
|
|
||||||
try:
|
try:
|
||||||
self.data["subject"] = data["subject"]
|
self.data["subject"] = data["subject"]
|
||||||
self.data["body"] = data["body"]
|
self.data["body"] = data["body"]
|
||||||
|
@ -37,6 +33,6 @@ class Message(MsgBase):
|
||||||
return self.data
|
return self.data
|
||||||
|
|
||||||
def process(self):
|
def process(self):
|
||||||
"""Method used for process the message"""
|
"""Process a message"""
|
||||||
logger.debug("Subject: %i bytes", len(self.subject))
|
logger.debug("Subject: %i bytes", len(self.subject))
|
||||||
logger.debug("Body: %i bytes", len(self.body))
|
logger.debug("Body: %i bytes", len(self.body))
|
||||||
|
|
|
@ -7,28 +7,27 @@ from messagetypes import MsgBase
|
||||||
# pylint: disable=attribute-defined-outside-init
|
# pylint: disable=attribute-defined-outside-init
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Vote(MsgBase):
|
class Vote(MsgBase):
|
||||||
"""Base method, helps to decode, encode and process the message"""
|
"""Base method, helps to decode, encode and process the message"""
|
||||||
def __init__(self): # pylint: disable=super-init-not-called
|
|
||||||
return
|
|
||||||
|
|
||||||
def decode(self, data):
|
def decode(self, data):
|
||||||
"""Method used for decoding the message"""
|
"""decode a vote"""
|
||||||
|
# pylint: disable=attribute-defined-outside-init
|
||||||
self.msgid = data["msgid"]
|
self.msgid = data["msgid"]
|
||||||
self.vote = data["vote"]
|
self.vote = data["vote"]
|
||||||
|
|
||||||
def encode(self, data):
|
def encode(self, data):
|
||||||
"""Method used for encoding the message"""
|
"""Encode a vote"""
|
||||||
# pylint: disable=no-member
|
super(Vote, self).__init__()
|
||||||
super(Vote, self).encode()
|
|
||||||
try:
|
try:
|
||||||
self.data["msgid"] = data["msgid"]
|
self.data["msgid"] = data["msgid"]
|
||||||
self.data["vote"] = data["vote"]
|
self.data["vote"] = data["vote"]
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
logger.error("Missing key %s", e.name)
|
logger.error("Missing key %s", e)
|
||||||
return self.data
|
return self.data
|
||||||
|
|
||||||
def process(self):
|
def process(self):
|
||||||
"""Method used for process the message"""
|
"""Encode a vote"""
|
||||||
logger.debug("msgid: %s", self.msgid)
|
logger.debug("msgid: %s", self.msgid)
|
||||||
logger.debug("vote: %s", self.vote)
|
logger.debug("vote: %s", self.vote)
|
||||||
|
|
|
@ -657,6 +657,7 @@ class _OpenSSL:
|
||||||
def loadOpenSSL():
|
def loadOpenSSL():
|
||||||
"""Method find and load the OpenSSL library"""
|
"""Method find and load the OpenSSL library"""
|
||||||
# pylint: disable=global-statement, protected-access, too-many-branches
|
# pylint: disable=global-statement, protected-access, too-many-branches
|
||||||
|
|
||||||
global OpenSSL
|
global OpenSSL
|
||||||
from os import path, environ
|
from os import path, environ
|
||||||
from ctypes.util import find_library
|
from ctypes.util import find_library
|
||||||
|
|
Reference in New Issue
Block a user