base_about.py 3.03 KB
#!/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 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()
        maincontent=loader.load("content_"+module+"_"+mainfnc+".html").generate(gitlastchange=gitlastchange, gitversions=gitversions)
        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 &Auml;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