base_about.py
4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/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 base_about(ncauth_base):
def get(self):
self.redirect("/")
@tornado.web.authenticated
def post(self):
nav=all
subnav=all
content=all
msglvl=""
msg=False
module="about"
mainfnc="show"
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)
gitlastchange=self.gitlastchanges()
gitversions=self.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):
#p = Popen("bash", stdout=PIPE, stdin=PIPE)
#p.stdin.write("git log \n")
#p.stdin.close()
# print(p.stdout.read())
#p1 = str(Popen(['git', 'log','-n10','--pretty=oneline'], stdout=PIPE) .communicate()[0])
#print('<div class="alert alert-info">')
self.gitversions()
#print('<br>')
self.gitlastchanges()
#print('</div>')
def gitlastchanges(self):
old_dir = os.getcwd()
os.chdir( os.path.join(os.path.dirname(__file__), "") )
os.chdir( '..')
p1 = str(Popen(['git', 'log','-n10','--pretty=format:"%ci %s"'], stdout=PIPE) .communicate()[0])
#p2 = Popen(['grep', '*'], stdin=p1.stdout, stdout=PIPE).communicate()[0]
# p1=str("<br />".join(p1.split("\n")))
thatLine = p1.replace('\\n', '<br />')
thatLine = thatLine.replace('b\'"', '<br>"')
print('<br>')
# h.crt_info_bx('letzte Änderungen:')
print(str(thatLine))
return thatLine
def gitversions(self):
#p = Popen("bash", stdout=PIPE, stdin=PIPE)
#p.stdin.write("git log \n")
#p.stdin.close()
# print(p.stdout.read())
#p1 = str(Popen(['git', 'log','-n10','--pretty=oneline'], stdout=PIPE) .communicate()[0])
os.chdir( os.path.join(os.path.dirname(__file__), "") )
os.chdir( '..')
p1 = Popen(['git', 'tag','-n'], stdout=PIPE)
p2 = str(Popen(['sort', '-V','-r'], stdin=p1.stdout, stdout=PIPE).communicate()[0])
# p1=str("<br />".join(p1.split("\n")))
thatLine = p2.replace('\\n', '<br />')
thatLine = thatLine.replace('b\'', '<br>')
print('<br>')
#h.crt_info_bx('Versionen:')
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