Changeset View
Changeset View
Standalone View
Standalone View
wallace/module_signature.py
Show All 27 Lines | |||||
import modules | import modules | ||||
import pykolab | import pykolab | ||||
from pykolab.auth import Auth | from pykolab.auth import Auth | ||||
from pykolab.translate import _ | from pykolab.translate import _ | ||||
# pylint: disable=invalid-name | # pylint: disable=invalid-name | ||||
log = pykolab.getLogger('pykolab.wallace') | log = pykolab.getLogger('pykolab.wallace/signature') | ||||
extra_log_params = {'qid': '-'} | |||||
log = pykolab.logger.LoggerAdapter(log, extra_log_params) | |||||
conf = pykolab.getConf() | conf = pykolab.getConf() | ||||
mybasepath = '/var/spool/pykolab/wallace/signature/' | mybasepath = '/var/spool/pykolab/wallace/signature/' | ||||
def __init__(): | def __init__(): | ||||
modules.register('signature', execute, description=description()) | modules.register('signature', execute, description=description()) | ||||
Show All 28 Lines | def attr_resolve(sender_info, attr): | ||||
for sender_attr_val in sender_info[attr]: | for sender_attr_val in sender_info[attr]: | ||||
values.append(auth.get_entry_attribute(None, sender_attr_val, attr_val)) | values.append(auth.get_entry_attribute(None, sender_attr_val, attr_val)) | ||||
return ", ".join(values) | return ", ".join(values) | ||||
# pylint: disable=too-many-branches,too-many-locals,too-many-statements | # pylint: disable=too-many-branches,too-many-locals,too-many-statements | ||||
def execute(*args, **kw): # noqa: C901 | def execute(*args, **kw): # noqa: C901 | ||||
global extra_log_params | |||||
# TODO: Test for correct call. | |||||
filepath = args[0] | |||||
extra_log_params['qid'] = os.path.basename(filepath) | |||||
if not os.path.isdir(mybasepath): | if not os.path.isdir(mybasepath): | ||||
os.makedirs(mybasepath) | os.makedirs(mybasepath) | ||||
for stage in ['incoming', 'ACCEPT']: | for stage in ['incoming', 'ACCEPT']: | ||||
if not os.path.isdir(os.path.join(mybasepath, stage)): | if not os.path.isdir(os.path.join(mybasepath, stage)): | ||||
os.makedirs(os.path.join(mybasepath, stage)) | os.makedirs(os.path.join(mybasepath, stage)) | ||||
# TODO: Test for correct call. | |||||
filepath = args[0] | |||||
if 'stage' in kw: | if 'stage' in kw: | ||||
log.debug(_("Issuing callback after processing to stage %s") % (kw['stage']), level=8) | log.debug(_("Issuing callback after processing to stage %s") % (kw['stage']), level=8) | ||||
log.debug(_("Testing cb_action_%s()") % (kw['stage']), level=8) | log.debug(_("Testing cb_action_%s()") % (kw['stage']), level=8) | ||||
if hasattr(modules, 'cb_action_%s' % (kw['stage'])): | if hasattr(modules, 'cb_action_%s' % (kw['stage'])): | ||||
log.debug(_("Attempting to execute cb_action_%s()") % (kw['stage']), level=8) | log.debug(_("Attempting to execute cb_action_%s()") % (kw['stage']), level=8) | ||||
exec('modules.cb_action_%s(%r, %r)' % (kw['stage'], 'signature', filepath)) | exec('modules.cb_action_%s(%r, %r)' % (kw['stage'], 'signature', filepath)) | ||||
return | return | ||||
▲ Show 20 Lines • Show All 150 Lines • Show Last 20 Lines |