Changeset View
Changeset View
Standalone View
Standalone View
wallace/module_gpgencrypt.py
Show All 34 Lines | |||||
import gnupg | import gnupg | ||||
import modules | import modules | ||||
import pykolab | import pykolab | ||||
from pykolab.translate import _ | from pykolab.translate import _ | ||||
log = pykolab.getLogger('pykolab.wallace') | log = pykolab.getLogger('pykolab.wallace/gpgencrypt') | ||||
extra_log_params = {'qid': '-'} | |||||
log = pykolab.logger.LoggerAdapter(log, extra_log_params) | |||||
conf = pykolab.getConf() | conf = pykolab.getConf() | ||||
mybasepath = '/var/spool/pykolab/wallace/gpgencrypt/' | mybasepath = '/var/spool/pykolab/wallace/gpgencrypt/' | ||||
def __init__(): | def __init__(): | ||||
modules.register('gpgencrypt', execute, description=description()) | modules.register('gpgencrypt', execute, description=description()) | ||||
def description(): | def description(): | ||||
Show All 29 Lines | |||||
Content-Disposition: inline; filename=\"encrypted.asc\"\n\n" | Content-Disposition: inline; filename=\"encrypted.asc\"\n\n" | ||||
msg.set_boundary(msg_boundary_gpg) | msg.set_boundary(msg_boundary_gpg) | ||||
msg.set_payload(msg_preamble + str(encrypted_content) + "\n" + msg_boundary_gpg) | msg.set_payload(msg_preamble + str(encrypted_content) + "\n" + msg_boundary_gpg) | ||||
return msg | return msg | ||||
def execute(*args, **kw): | def execute(*args, **kw): | ||||
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 kw.has_key('stage'): | if kw.has_key('stage'): | ||||
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'],'gpgencrypt',filepath)) | exec('modules.cb_action_%s(%r, %r)' % (kw['stage'],'gpgencrypt',filepath)) | ||||
log.debug(_("Executing module gpgencrypt for %r, %r") % (args, kw), level=8) | log.debug(_("Executing module gpgencrypt for %r, %r") % (args, kw), level=8) | ||||
▲ Show 20 Lines • Show All 181 Lines • Show Last 20 Lines |