Commit 14f45818 by netz.coop

v0.1.5 Posttools

1 parent 4e8c5fc3
2018-01-16 v0.1.5 Posttools
2018-01-16 v0.1.4 startscript kill
2018-01-16 v0.1.3 USER/DOMAIN/ALIAS select statement
2018-01-16 v0.1.2 BCC select statement
......
......@@ -10,6 +10,7 @@ import tornado
import os.path
import sys
from subprocess import Popen, PIPE
#from itertools import izip
#from baseclasses.htmltools import htmltools
from ncauth.ncauth_base import ncauth_base
......@@ -32,7 +33,9 @@ class base_about(ncauth_base):
subnavigation=loader.load("subnav_"+module+"_"+mainfnc+".html").generate(subnav=subnav)
gitlastchange=self.gitlastchanges()
gitversions=self.gitversions()
maincontent=loader.load("content_"+module+"_"+mainfnc+".html").generate(gitlastchange=gitlastchange, gitversions=gitversions)
mailstuff=self.mailcheck()
mailstufflist=self.mailchecktuple()
maincontent=loader.load("content_"+module+"_"+mainfnc+".html").generate(gitlastchange=gitlastchange, gitversions=gitversions,mailstuff=mailstuff,mailstufflist=mailstufflist)
self.render('base.html', navigation=navigation, subnavigation=subnavigation, maincontent=maincontent, msg=msg, msglvl=msglvl)
def printabout(self):
......@@ -80,3 +83,35 @@ class base_about(ncauth_base):
print(str(thatLine))
return thatLine
def mailcheck(self):
old_dir = os.getcwd()
os.chdir( os.path.join(os.path.dirname(__file__), "") )
os.chdir( '..')
p1 = str(Popen(['/usr/sbin/postqueue','-p'],stdout=PIPE) .communicate()[0])
thatLine = p1.replace('\\n', '<br />')
thatLine = thatLine.replace('b\'"', '<br>"')
print(str(thatLine))
return thatLine
def mailchecktuple(self):
old_dir = os.getcwd()
os.chdir( os.path.join(os.path.dirname(__file__), "") )
os.chdir( '..')
# p1 = Popen(['/usr/sbin/postqueue','-p'],stdout=PIPE)
p1 = str(Popen("/usr/sbin/postqueue -p | awk 'NR % 4 == 2' | awk '{print $1 \"\\n\" $7 }' |egrep -v '^-' | egrep -v '^$' " , stdout=PIPE, shell=True).communicate()[0])
# p3 = Popen(['egrep', '-v','"\'-\'"'], stdin=p2.stdout, stdout=PIPE)
# p4 = Popen(['egrep', '-v','"^$"'], stdin=p3.stdout, stdout=PIPE)
# p5 = Popen(['egrep', '-v','"^\("'], stdin=p4.stdout, stdout=PIPE).communicate()[0]
thatLine = p1.replace('\\n', ';')
thatLine = thatLine.replace('b\'', '')
thatLine = thatLine.replace('\'', '')
#print(str(thatLine))
list = [item for item in thatLine.split(';') if item.strip()]
# tuple = (item for item in thatLine.split(';') if item.strip())
i = iter(list)
dict = (zip(i, i))
return dict
#!/usr/bin/python3
# -*- coding: UTF-8 -*-# enable debugging
from mysql.connector import MySQLConnection, Error
from read_dbconfig import read_db_config
import tornado.ioloop
import tornado.web
import tornado.escape
import tornado
import os.path
import sys
from subprocess import Popen, PIPE
#from itertools import izip
#from baseclasses.htmltools import htmltools
from ncauth.ncauth_base import ncauth_base
class mailcnf_posttools(ncauth_base):
def get(self):
self.redirect("/")
@tornado.web.authenticated
def post(self):
nav=all
subnav=all
content=all
msglvl=""
msg=False
mainfnc="posttools"
#module= self.get_argument("module", None, False)
#mainfnc= self.get_argument("mainfnc", None, False)
#if module== False:
module="mailcnf"
#if mainfnc== False:
mainfnc="posttools"
id= self.get_argument("id", None, False)
mailname= self.get_argument("mailname", None, False)
action= self.get_argument("action", None, False)
fnc= self.get_argument("fnc", None, False)
if action == 'postersuper1':
msg = self.postsuperdel(id,mailname)
msglvl="alert-info"
loader =tornado. template.Loader(os.path.join(os.path.dirname(__file__), "../templates"))
navigation=loader.load("navigation.html").generate(nav=nav)
subnavigation=loader.load("subnav_"+module+"_"+mainfnc+".html").generate(subnav=subnav)
mailstuff=self.mailcheck()
mailstufflist=self.mailchecktuple()
maincontent=loader.load("content_"+module+"_"+mainfnc+".html").generate(mailstuff=mailstuff,mailstufflist=mailstufflist)
self.render('base.html', navigation=navigation, subnavigation=subnavigation, maincontent=maincontent, msg=msg, msglvl=msglvl)
def mailcheck(self):
old_dir = os.getcwd()
os.chdir( os.path.join(os.path.dirname(__file__), "") )
os.chdir( '..')
p1 = str(Popen(['/usr/sbin/postqueue','-p'],stdout=PIPE) .communicate()[0])
thatLine = p1.replace('\\n', '<br />')
thatLine = thatLine.replace('b\'', '<br>')
thatLine = thatLine.replace('\'', '')
print(str(thatLine))
return thatLine
def mailchecktuple(self):
old_dir = os.getcwd()
os.chdir( os.path.join(os.path.dirname(__file__), "") )
os.chdir( '..')
# p1 = Popen(['/usr/sbin/postqueue','-p'],stdout=PIPE)
p1 = str(Popen("/usr/sbin/postqueue -p | awk 'NR % 4 == 2' | awk '{print $1 \"\\n\" $7 }' |egrep -v '^-' | egrep -v '^$' " , stdout=PIPE, shell=True).communicate()[0])
# p3 = Popen(['egrep', '-v','"\'-\'"'], stdin=p2.stdout, stdout=PIPE)
# p4 = Popen(['egrep', '-v','"^$"'], stdin=p3.stdout, stdout=PIPE)
# p5 = Popen(['egrep', '-v','"^\("'], stdin=p4.stdout, stdout=PIPE).communicate()[0]
thatLine = p1.replace('\\n', ';')
thatLine = thatLine.replace('b\'', '')
thatLine = thatLine.replace('\'', '')
#print(str(thatLine))
list = [item for item in thatLine.split(';') if item.strip()]
# tuple = (item for item in thatLine.split(';') if item.strip())
i = iter(list)
dict = (zip(i, i))
return dict
def postsuperdel(self,id,mailname=''):
print('')
old_dir = os.getcwd()
os.chdir( os.path.join(os.path.dirname(__file__), "") )
os.chdir( '..')
p1 = str(Popen("postsuper -d "+str(id) , stdout=PIPE, shell=True).communicate()[0])
return "Nachricht "+str(id)+" von "+str(mailname)+" gelöscht"
\ No newline at end of file
......@@ -14,6 +14,7 @@ from mailsrv.mailcnf_user import mailcnf_user
from mailsrv.mailcnf_domain import mailcnf_domain
from mailsrv.mailcnf_alias import mailcnf_alias
from mailsrv.mailcnf_bcc import mailcnf_bcc
from mailsrv.mailcnf_posttools import mailcnf_posttools
from base.base_about import base_about
class srvcnf(tornado.web.RequestHandler):
......@@ -55,6 +56,7 @@ def make_app():
(r"/mailcnf/domain" , mailcnf_domain),
(r"/mailcnf/alias" , mailcnf_alias),
(r"/mailcnf/bcc" , mailcnf_bcc),
(r"/mailcnf/posttools" , mailcnf_posttools),
(r"/base/about" , base_about),
],
login_url="/login",
......
......@@ -30,9 +30,11 @@
{% try %}
{% if msg %}
<div class="{{ msglvl }}">
<br><br>
<div class="msg {{ msglvl }}">
<b> {{ msg }}</b>
</div>
<br>
{% end %}
{% except %}
{% end %}
......
......@@ -10,3 +10,6 @@
{% raw gitversions %}
</div>
<br><br>
<div class="alert-info" style="alert">postque -q</div>
<br>
<div>
{% raw mailstuff %}
</div>
<br>
<br>
<div class="alert-info" style="alert">Aktionen postsuper -d $ID </div>
<br>
{% for entry in mailstufflist %}
<div>
<form action="/mailcnf/posttools" method="POST">
<input type="hidden" size="70" name="fnc" value="mailcnf">
<input type="hidden" value="posttools" size="70" name="mainfnc" class="'">
<input type="hidden" value="about" size="70" name="module" class="'">
<input type="hidden" value="postersuper1" size="70" name="action" class="'">
<input type="hidden" value="{% raw entry[0] %}" size="70" name="id" class="'">
<input type="hidden" value="{% raw entry[1] %}" size="70" name="mailname" class="'">
<button type="submit" class="btn btn-info btn-block btn-xs">Lösche {% raw entry[0] %} {% raw entry[1] %}</button>
</form>
</div>
<br>
{% end %}
......@@ -5,6 +5,11 @@
<input type="hidden" size="70" name="mainfnc" value="bcclist">
<button type="submit" class="btn btn-success">About</button>
</form>
<form action="/mailcnf/posttools" method="POST">
<input type="hidden" size="70" name="module" value="mailcnf">
<input type="hidden" size="70" name="mainfnc" value="bcclist">
<button type="submit" class="btn btn-success">Mail Posttools</button>
</form>
</div>
<form action="/mailcnf/user" method="POST">
<input type="hidden" size="70" name="module" value="mailcnf">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!