Esempio n. 1
0
def test_base_css_light():
    expected = """
.ansi_fore { color: #000000; }
.ansi_back { background-color: #FFFFFF; }
.ansi1 { font-weight: bold; }
.ansi3 { font-weight: italic; }
.ansi4 { text-decoration: underline; }
.ansi9 { text-decoration: line-through; }
.ansi30 { color: #000000; }
.ansi31 { color: #FF0000; }
.ansi32 { color: #00FF00; }
.ansi33 { color: #FFFF00; }
.ansi34 { color: #0000FF; }
.ansi35 { color: #FF00FF; }
.ansi36 { color: #00FFFF; }
.ansi37 { color: #FFFFFF; }
.ansi40 { background-color: #000000; }
.ansi41 { background-color: #FF0000; }
.ansi42 { background-color: #00FF00; }
.ansi43 { background-color: #FFFF00; }
.ansi44 { background-color: #0000FF; }
.ansi45 { background-color: #FF00FF; }
.ansi46 { background-color: #00FFFF; }
.ansi47 { background-color: #FFFFFF; }
.ansi90 { color: #000000; }
.ansi91 { color: #FF0000; }
.ansi92 { color: #00FF00; }
.ansi93 { color: #FFFF00; }
.ansi94 { color: #0000FF; }
.ansi95 { color: #FF00FF; }
.ansi96 { color: #00FFFF; }
.ansi97 { color: #FFFFFF; }
""".strip()
    actual = ansiconv.base_css(dark=False)
    assert expected == actual
Esempio n. 2
0
def report(cfg, contents):
    mb = "<html><head><title>%s</title>\n" % cfg.get(SETTINGS, 'mail_title')
    mb += "<style>body { font-family:Arial,sans-serif; } %s</style>\n" % ansiconv.base_css()
    mb += "</head></body>\n"
    mb += "<h1>%s</h1>\n" % cfg.get(SETTINGS, 'mail_title')
    mb += "<p>%s</p>\n" % cfg.get(SETTINGS, 'mail_ingress')
    mb += "<hr><p><pre>\n"
    mb += contents
    mb += "</pre></p><hr>\n"
    mb += "<p>This message was created by <b>GitReporter</b> on <b>%s</b> at %s</p>\n" % (node(), datetime.now())
    mb += "</body></html>\n"

    # create mime mail
    msg = MIMEText(mb, 'html')
    msg['Subject'] = cfg.get(SETTINGS, 'mail_subject')
    msg['From'] = cfg.get(SETTINGS, 'mail_from')
    msg['To'] = cfg.get(SETTINGS, 'mail_receptient')

    # save file as well
    if cfg.get(SETTINGS, 'mail_result_file'):
        with open(cfg.get(SETTINGS, 'mail_result_file'), 'w') as f:
            f.write(mb)
        print('*** report file written')

    # send mail or not
    if cfg.getboolean(SETTINGS, 'mail_enable'):
        # send mail
        s = smtplib.SMTP(cfg.get(SETTINGS, 'mail_smtp'))
        s.sendmail(msg['From'], [ msg['To'] ], msg.as_string())
        s.quit()
        print('*** email sent')
Esempio n. 3
0
def base64_decode(raw_id_1, raw_id_2):
    std_str = '<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/tonsky/[email protected]/distr/fira_code.css"><style>.code-font-medium {font-family: \'Fira Code\', monospace;font-size: medium;}</style><style>'
    try:
        str_raw_html = base64.b64decode((''.join(open('static/datalogs/{}_{}.txt'.format(raw_id_1, raw_id_2), 'r').readlines())).encode()).decode().replace('\n', '<br>')
        html_conv = ansiconv.to_html(str_raw_html).replace('ansi37', '')
        str_html = '<body class="code-font-medium">{}</body></html>'.format(html_conv)
        st_css = ansiconv.base_css()
        return std_str + st_css + '</style></head>' + str_html
    except Exception as ident:
        return 'Error occurred. {}'.format(ident)
Esempio n. 4
0
 def __init__(self, title, details, parent = None):
     super(self.__class__, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint | QtCore.Qt.MSWindowsFixedSizeDialogHint)
     self.setupUi(self)  # This is defined in design.py file automatically
                         # It sets up layout and widgets that are defined
     
     self.setWindowTitle("IEEE Testbank Tool - " + title)
     
     # Pre-processing
     details = str(details).replace("\n", "<br />\n")
     
     self.detailsTxt.setText("<style>%s</style>%s" % (ansiconv.base_css(), ansiconv.to_html(details)))
Esempio n. 5
0
    def to_html(self):
        import ansiconv
        output = """
            <style>
              {}

              div.timelinetool {{
                font-family: monospace;
                white-space: pre-wrap;
                padding: 10px;
              }}
            </style>
            <div class="timelinetool ansi_fore ansi_back">{}</div>
            """.format(ansiconv.base_css(), ansiconv.to_html(str(self)))
        return output
Esempio n. 6
0
    def to_html(self):
        import ansiconv
        output = """
            <style>
              {}

              div.timelinetool {{
                font-family: monospace;
                white-space: pre-wrap;
                padding: 10px;
              }}
            </style>
            <div class="timelinetool ansi_fore ansi_back">{}</div>
            """.format(ansiconv.base_css(), ansiconv.to_html(str(self)))
        return output
Esempio n. 7
0
def get_ansiconv_css():
    return ansiconv.base_css()
Esempio n. 8
0
def get_ansiconv_css():
    return ansiconv.base_css()
    def log(id):

        testroles_row = testroles.query.filter(testroles.id == id).order_by(testroles.id).first()
        html = ansiconv.to_html(testroles_row.testrole_log)
        css = ansiconv.base_css()
        return render_template('logs.html', testroles_row=testroles_row, html=html, css=css)