|
@@ -9,7 +9,7 @@
|
|
|
|
|
|
|
|
|
_NAME = 'pmailq'
|
|
|
-_HELP = "[OPTIONS] [ show | showcsv | del ]"
|
|
|
+_HELP = "[OPTIONS] [ list | parse | del ]"
|
|
|
_DESC = "%s postfix mail queue manager" % _NAME
|
|
|
_VERSION = '0.1'
|
|
|
_AUTHOR = 'Emmanuel Bouthenot <kolter@openics.org>'
|
|
@@ -125,7 +125,7 @@ class mailqueue:
|
|
|
return True
|
|
|
|
|
|
|
|
|
- def show(self):
|
|
|
+ def cmd_list(self):
|
|
|
for m in self.mailqueue:
|
|
|
out = "%s\n" % m['id']
|
|
|
out += " -date: %s\n" % m['date']
|
|
@@ -144,7 +144,7 @@ class mailqueue:
|
|
|
print out
|
|
|
|
|
|
|
|
|
- def showcsv(self):
|
|
|
+ def cmd_parse(self):
|
|
|
for m in self.mailqueue:
|
|
|
e = []
|
|
|
i = []
|
|
@@ -157,7 +157,7 @@ class mailqueue:
|
|
|
print "%s|%s|%s|%d|%d|%s" % (m['id'], m['date'], m['size'], int(m['active']), int(m['hold']), ",".join(n['dest']))
|
|
|
|
|
|
|
|
|
- def delete(self):
|
|
|
+ def cmd_del(self):
|
|
|
for m in self.mailqueue:
|
|
|
e = []
|
|
|
i=[]
|
|
@@ -179,16 +179,16 @@ def main():
|
|
|
parser = OptionParser(usage=usage, description=desc, version=("%s %s" % (_NAME, _VERSION)))
|
|
|
|
|
|
opts = OptionGroup(parser, "filters")
|
|
|
- opts.add_option("-e", "--email", dest="email", type="string", metavar="EMAIL", help="select entries in queue with email matching EMAIL")
|
|
|
+ opts.add_option("-e", "--email", dest="email", type="string", metavar="PATTERN", help="select entries in queue with email matching PATTERN")
|
|
|
parser.set_defaults(email=None)
|
|
|
- opts.add_option("-m", "--msg", dest="msg", type="string", metavar="MSG", help="select entries in queue with error message matching MSG")
|
|
|
+ opts.add_option("-m", "--msg", dest="msg", type="string", metavar="PATTERN", help="select entries in queue with error message matching PATTERN")
|
|
|
parser.set_defaults(msg=None)
|
|
|
- opts.add_option("-l", "--size-lower", dest="lowsize", type="int", metavar="SIZE", help="select entries in queue with size smaller than SIZE")
|
|
|
+ opts.add_option("-l", "--size-lower", dest="lowsize", type="int", metavar="SIZE", help="select entries in queue with size lower than SIZE bytes")
|
|
|
parser.set_defaults(lowsize=0)
|
|
|
- opts.add_option("-u", "--size-upper", dest="upsize", type="int", metavar="SIZE", help="select entries in queue with size upper than SIZE")
|
|
|
+ opts.add_option("-u", "--size-upper", dest="upsize", type="int", metavar="SIZE", help="select entries in queue with size upper than SIZE bytes")
|
|
|
parser.set_defaults(upsize=0)
|
|
|
opts.add_option("-a", "--active", dest="active", default=False, action="store_true", help="select 'active' entries in queue (default: no)")
|
|
|
- opts.add_option("-o", "--hold", dest="hold", default=False, action="store_true", help="select on 'hold' entries in queue (default: no)")
|
|
|
+ opts.add_option("-o", "--hold", dest="hold", default=False, action="store_true", help="select 'on hold' entries in queue (default: no)")
|
|
|
parser.add_option_group(opts)
|
|
|
|
|
|
(options, args) = parser.parse_args()
|
|
@@ -202,13 +202,13 @@ def main():
|
|
|
m.add_filter("hold", options.hold)
|
|
|
|
|
|
if args == []:
|
|
|
- m.show()
|
|
|
- elif args[0] == "show":
|
|
|
- m.show()
|
|
|
- elif args[0] == "showcsv":
|
|
|
- m.showcsv()
|
|
|
+ m.cmd_list()
|
|
|
+ elif args[0] == "list":
|
|
|
+ m.cmd_list()
|
|
|
+ elif args[0] == "parse":
|
|
|
+ m.cmd_parse()
|
|
|
elif args[0] == "del":
|
|
|
- m.delete()
|
|
|
+ m.cmd_del()
|
|
|
else:
|
|
|
print "%s %s" % (_NAME, _HELP)
|
|
|
|