More messagetypes hardening
- only load modules at program start
This commit is contained in:
parent
757740369b
commit
fde194f9b0
|
@ -3,6 +3,7 @@ from os import path, listdir
|
||||||
from string import lower
|
from string import lower
|
||||||
|
|
||||||
from debug import logger
|
from debug import logger
|
||||||
|
import messagetypes
|
||||||
import paths
|
import paths
|
||||||
|
|
||||||
class MsgBase(object):
|
class MsgBase(object):
|
||||||
|
@ -15,9 +16,8 @@ def constructObject(data):
|
||||||
if data[""] not in whitelist:
|
if data[""] not in whitelist:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
m = import_module("messagetypes." + data[""])
|
classBase = getattr(getattr(messagetypes, data[""]), data[""].title())
|
||||||
classBase = getattr(m, data[""].title())
|
except (NameError, AttributeError):
|
||||||
except (NameError, ImportError):
|
|
||||||
logger.error("Don't know how to handle message type: \"%s\"", data[""], exc_info=True)
|
logger.error("Don't know how to handle message type: \"%s\"", data[""], exc_info=True)
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
|
@ -43,7 +43,7 @@ else:
|
||||||
if splitted[1] != ".py":
|
if splitted[1] != ".py":
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
import_module("." + splitted[0], "messagetypes")
|
import_module(".{}".format(splitted[0]), "messagetypes")
|
||||||
except ImportError:
|
except ImportError:
|
||||||
logger.error("Error importing %s", mod, exc_info=True)
|
logger.error("Error importing %s", mod, exc_info=True)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user