Changed word e-mail to email in all log messages
This commit is contained in:
@@ -95,7 +95,7 @@ def list_quarantine_emails(config, args):
|
||||
# get quarantine object
|
||||
quarantine = _get_quarantine_obj(config, args.quarantine)
|
||||
if quarantine == None:
|
||||
raise RuntimeError("quarantine type is set to None, unable to list e-mails")
|
||||
raise RuntimeError("quarantine type is set to None, unable to list emails")
|
||||
|
||||
# find emails and transform some metadata values to strings
|
||||
emails = quarantine.find(mailfrom=args.mailfrom, recipients=args.recipients, older_than=args.older_than)
|
||||
@@ -198,7 +198,7 @@ def release_email(config, args):
|
||||
|
||||
quarantine = _get_quarantine_obj(config, args.quarantine)
|
||||
if quarantine == None:
|
||||
raise RuntimeError("quarantine type is set to None, unable to release e-mail")
|
||||
raise RuntimeError("quarantine type is set to None, unable to release email")
|
||||
|
||||
quarantine.release(args.quarantine_id, args.recipient)
|
||||
if args.recipient:
|
||||
@@ -212,13 +212,13 @@ def delete_email(config, args):
|
||||
|
||||
quarantine = _get_quarantine_obj(config, args.quarantine)
|
||||
if quarantine == None:
|
||||
raise RuntimeError("quarantine type is set to None, unable to delete e-mail")
|
||||
raise RuntimeError("quarantine type is set to None, unable to delete email")
|
||||
|
||||
quarantine.delete(args.quarantine_id, args.recipient)
|
||||
if args.recipient:
|
||||
logger.info("successfully deleted e-mail [quarantine-id: {}] to '{}' from quarantine '{}'".format(args.quarantine_id, args.recipient, args.quarantine))
|
||||
logger.info("successfully deleted email [quarantine-id: {}] to '{}' from quarantine '{}'".format(args.quarantine_id, args.recipient, args.quarantine))
|
||||
else:
|
||||
logger.info("successfully deleted e-mail [quarantine-id: {}] from quarantine '{}'".format(args.quarantine_id, args.quarantine))
|
||||
logger.info("successfully deleted email [quarantine-id: {}] from quarantine '{}'".format(args.quarantine_id, args.quarantine))
|
||||
|
||||
|
||||
class StdErrFilter(logging.Filter):
|
||||
@@ -252,27 +252,27 @@ def main():
|
||||
quarantine_parser.add_argument("quarantine", metavar="QUARANTINE", help="Quarantine name.")
|
||||
quarantine_subparsers = quarantine_parser.add_subparsers()
|
||||
# quarantine list command
|
||||
quarantine_list_parser = quarantine_subparsers.add_parser("list", description="List e-mails in quarantines.", help="List e-mails in quarantine.", formatter_class=formatter_class)
|
||||
quarantine_list_parser.add_argument("-f", "--from", dest="mailfrom", help="Filter e-mails by from address.", default=None, nargs="+")
|
||||
quarantine_list_parser.add_argument("-t", "--to", dest="recipients", help="Filter e-mails by recipient address.", default=None, nargs="+")
|
||||
quarantine_list_parser.add_argument("-o", "--older-than", dest="older_than", help="Filter e-mails by age (days).", default=None, type=float)
|
||||
quarantine_list_parser.add_argument("-b", "--batch", help="Print results using only e-mail quarantine IDs, each on a new line.", action="store_true")
|
||||
quarantine_list_parser = quarantine_subparsers.add_parser("list", description="List emails in quarantines.", help="List emails in quarantine.", formatter_class=formatter_class)
|
||||
quarantine_list_parser.add_argument("-f", "--from", dest="mailfrom", help="Filter emails by from address.", default=None, nargs="+")
|
||||
quarantine_list_parser.add_argument("-t", "--to", dest="recipients", help="Filter emails by recipient address.", default=None, nargs="+")
|
||||
quarantine_list_parser.add_argument("-o", "--older-than", dest="older_than", help="Filter emails by age (days).", default=None, type=float)
|
||||
quarantine_list_parser.add_argument("-b", "--batch", help="Print results using only email quarantine IDs, each on a new line.", action="store_true")
|
||||
quarantine_list_parser.set_defaults(func=list_quarantine_emails)
|
||||
# quarantine release command
|
||||
quarantine_release_parser = quarantine_subparsers.add_parser("release", description="Release e-mail from quarantine.", help="Release e-mail from quarantine.", formatter_class=formatter_class)
|
||||
quarantine_release_parser = quarantine_subparsers.add_parser("release", description="Release email from quarantine.", help="Release email from quarantine.", formatter_class=formatter_class)
|
||||
quarantine_release_parser.add_argument("quarantine_id", metavar="ID", help="Quarantine ID.")
|
||||
quarantine_release_parser.add_argument("-n", "--disable-syslog", dest="syslog", help="Disable syslog messages.", action="store_false")
|
||||
quarantine_release_parser_group = quarantine_release_parser.add_mutually_exclusive_group(required=True)
|
||||
quarantine_release_parser_group.add_argument("-t", "--to", dest="recipient", help="Release e-mail for one recipient address.")
|
||||
quarantine_release_parser_group.add_argument("-a", "--all", help="Release e-mail for all recipients.", action="store_true")
|
||||
quarantine_release_parser_group.add_argument("-t", "--to", dest="recipient", help="Release email for one recipient address.")
|
||||
quarantine_release_parser_group.add_argument("-a", "--all", help="Release email for all recipients.", action="store_true")
|
||||
quarantine_release_parser.set_defaults(func=release_email)
|
||||
# quarantine delete command
|
||||
quarantine_delete_parser = quarantine_subparsers.add_parser("delete", description="Delete e-mail from quarantine.", help="Delete e-mail from quarantine.", formatter_class=formatter_class)
|
||||
quarantine_delete_parser = quarantine_subparsers.add_parser("delete", description="Delete email from quarantine.", help="Delete email from quarantine.", formatter_class=formatter_class)
|
||||
quarantine_delete_parser.add_argument("quarantine_id", metavar="ID", help="Quarantine ID.")
|
||||
quarantine_delete_parser.add_argument("-n", "--disable-syslog", dest="syslog", help="Disable syslog messages.", action="store_false")
|
||||
quarantine_delete_parser_group = quarantine_delete_parser.add_mutually_exclusive_group(required=True)
|
||||
quarantine_delete_parser_group.add_argument("-t", "--to", dest="recipient", help="Delete e-mail for one recipient address.")
|
||||
quarantine_delete_parser_group.add_argument("-a", "--all", help="Delete e-mail for all recipients.", action="store_true")
|
||||
quarantine_delete_parser_group.add_argument("-t", "--to", dest="recipient", help="Delete email for one recipient address.")
|
||||
quarantine_delete_parser_group.add_argument("-a", "--all", help="Delete email for all recipients.", action="store_true")
|
||||
quarantine_delete_parser.set_defaults(func=delete_email)
|
||||
|
||||
# whitelist command group
|
||||
@@ -283,7 +283,7 @@ def main():
|
||||
whitelist_list_parser = whitelist_subparsers.add_parser("list", description="List whitelist entries.", help="List whitelist entries.", formatter_class=formatter_class)
|
||||
whitelist_list_parser.add_argument("-f", "--from", dest="mailfrom", help="Filter entries by from address.", default=None, nargs="+")
|
||||
whitelist_list_parser.add_argument("-t", "--to", dest="recipients", help="Filter entries by recipient address.", default=None, nargs="+")
|
||||
whitelist_list_parser.add_argument("-o", "--older-than", dest="older_than", help="Filter e-mails by last used date (days).", default=None, type=float)
|
||||
whitelist_list_parser.add_argument("-o", "--older-than", dest="older_than", help="Filter emails by last used date (days).", default=None, type=float)
|
||||
whitelist_list_parser.set_defaults(func=list_whitelist)
|
||||
# whitelist add command
|
||||
whitelist_add_parser = whitelist_subparsers.add_parser("add", description="Add whitelist entry.", help="Add whitelist entry.", formatter_class=formatter_class)
|
||||
|
||||
@@ -34,24 +34,24 @@ class BaseQuarantine(object):
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
def add(self, queueid, mailfrom, recipients, fp):
|
||||
"Add e-mail to quarantine."
|
||||
"Add email to quarantine."
|
||||
fp.seek(0)
|
||||
return ""
|
||||
|
||||
def find(self, mailfrom=None, recipients=None, older_than=None):
|
||||
"Find e-mails in quarantine."
|
||||
"Find emails in quarantine."
|
||||
return
|
||||
|
||||
def get_metadata(self, quarantine_id):
|
||||
"Return metadata of quarantined e-mail."
|
||||
"Return metadata of quarantined email."
|
||||
return
|
||||
|
||||
def delete(self, quarantine_id, recipient=None):
|
||||
"Delete e-mail from quarantine."
|
||||
"Delete email from quarantine."
|
||||
return
|
||||
|
||||
def release(self, quarantine_id, recipient=None):
|
||||
"Release e-mail from quarantine."
|
||||
"Release email from quarantine."
|
||||
return
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ class FileQuarantine(BaseQuarantine):
|
||||
raise RuntimeError("unable to remove data file: {}".format(e))
|
||||
|
||||
def add(self, queueid, mailfrom, recipients, fp):
|
||||
"Add e-mail to file quarantine and return quarantine-id."
|
||||
"Add email to file quarantine and return quarantine-id."
|
||||
super(FileQuarantine, self).add(queueid, mailfrom, recipients, fp)
|
||||
quarantine_id = "{}_{}".format(datetime.now().strftime("%Y%m%d%H%M%S"), queueid)
|
||||
|
||||
@@ -128,7 +128,7 @@ class FileQuarantine(BaseQuarantine):
|
||||
return quarantine_id
|
||||
|
||||
def get_metadata(self, quarantine_id):
|
||||
"Return metadata of quarantined e-mail."
|
||||
"Return metadata of quarantined email."
|
||||
super(FileQuarantine, self).get_metadata(quarantine_id)
|
||||
|
||||
metafile = os.path.join(self.directory, "{}{}".format(quarantine_id, self._metadata_suffix))
|
||||
@@ -146,7 +146,7 @@ class FileQuarantine(BaseQuarantine):
|
||||
return metadata
|
||||
|
||||
def find(self, mailfrom=None, recipients=None, older_than=None):
|
||||
"Find e-mails in quarantine."
|
||||
"Find emails in quarantine."
|
||||
super(FileQuarantine, self).find(mailfrom, recipients, older_than)
|
||||
if type(mailfrom) == str: mailfrom = [mailfrom]
|
||||
if type(recipients) == str: recipients = [recipients]
|
||||
@@ -177,13 +177,13 @@ class FileQuarantine(BaseQuarantine):
|
||||
return emails
|
||||
|
||||
def delete(self, quarantine_id, recipient=None):
|
||||
"Delete e-mail in quarantine."
|
||||
"Delete email in quarantine."
|
||||
super(FileQuarantine, self).delete(quarantine_id, recipient)
|
||||
|
||||
try:
|
||||
metadata = self.get_metadata(quarantine_id)
|
||||
except RuntimeError as e:
|
||||
raise RuntimeError("unable to delete e-mail: {}".format(e))
|
||||
raise RuntimeError("unable to delete email: {}".format(e))
|
||||
|
||||
if recipient == None:
|
||||
self._remove(quarantine_id)
|
||||
@@ -198,13 +198,13 @@ class FileQuarantine(BaseQuarantine):
|
||||
self._save_metafile(quarantine_id, metadata)
|
||||
|
||||
def release(self, quarantine_id, recipient=None):
|
||||
"Release e-mail from quarantine."
|
||||
"Release email from quarantine."
|
||||
super(FileQuarantine, self).release(quarantine_id, recipient)
|
||||
|
||||
try:
|
||||
metadata = self.get_metadata(quarantine_id)
|
||||
except RuntimeError as e:
|
||||
raise RuntimeError("unable to release e-mail: {}".format(e))
|
||||
raise RuntimeError("unable to release email: {}".format(e))
|
||||
|
||||
datafile = os.path.join(self.directory, quarantine_id)
|
||||
if recipient != None:
|
||||
@@ -224,7 +224,7 @@ class FileQuarantine(BaseQuarantine):
|
||||
try:
|
||||
mailer.smtp_send(self.config["smtp_host"], self.config["smtp_port"], metadata["from"], recipient, mail)
|
||||
except Exception as e:
|
||||
raise RuntimeError("error while sending e-mail to '{}': {}".format(recipient, e))
|
||||
raise RuntimeError("error while sending email to '{}': {}".format(recipient, e))
|
||||
|
||||
self.delete(quarantine_id, recipient)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user