<commit_before># -*- coding:  UTF-8 -*-
__author__ = '<NAME>'
__mail__ = '<EMAIL>'
'''
created 2015/5/22 
'''
from SocketServer import ThreadingMixIn
from BaseHTTPServer import HTTPServer,BaseHTTPRequestHandler
import os,sys
import StringIO, cgi , urllib
pardir =os.path.dirname(os.path.realpath(os.getcwd()))
libpath = os.path.sep.join([pardir,'lib'])
if libpath not in sys.path:
    sys.path.insert(0,libpath)

class HttpHandler(BaseHTTPRequestHandler):
    logger=None
    hdrlog =None
    runcfg = None
    fDBReseting=False
    httpserver =None
    rootdir = None
    def __del__(self):
        #self.hdrlog.close()
        #print('end http server')
        pass





    def list_dir(self, path, related_path):
        """Helper to produce a directory listing (absent index.html).

        Return value is either a file object, or None (indicating an
        error).  In either case, the headers are sent, making the
        interface the same as for send_head().

        """
        content =""
        try:
            list = os.listdir(path)
        except os.error:
            self.send_error(404, "No permission to list directory")
            return ""
        list.sort(key=lambda a: a.lower())
        #f = StringIO()
        displaypath = cgi.escape(urllib.unquote(self.path))
        content='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'
        content+="<html>\n<title>Directory listing for %s</title>\n" % displaypath
        content+="<body>\n<h2>Directory listing for %s</h2>\n" % displaypath
        content+="<hr>\n<ul>\n"
        content+='''
        <SCRIPT>
    function post( id, script, dest )
        {
            element = document.getElementById(id);
            value = element.value
            params = 'script='+encodeURI(script)+'&arg='+encodeURI(value)
            var xmlhttp;

            if (window.XMLHttpRequest)
            {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp=new XMLHttpRequest();
            }
            else
            {// code for IE6, IE5
                xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
            }

            xmlhttp.onreadystatechange=function()
            {
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {
                    setTimeout("window.close()",3000);
                }
            }
            xmlhttp.open("POST",dest,true);
            xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
            xmlhttp.send( params );
        }

        </SCRIPT>
        '''
        for name in list:
            fullname = os.path.join(path, name)
            displayname = linkname = name
            # Append / for directories or @ for symbolic links
            if os.path.isdir(fullname):<commit_msg>fun: show result of run case/suite in new html page and alert message box<commit_after># -*- coding:  UTF-8 -*-
__author__ = '<NAME>'
__mail__ = '<EMAIL>'
'''
created 2015/5/22 
'''
from SocketServer import ThreadingMixIn
from BaseHTTPServer import HTTPServer,BaseHTTPRequestHandler
import os,sys
import StringIO, cgi , urllib
pardir =os.path.dirname(os.path.realpath(os.getcwd()))
libpath = os.path.sep.join([pardir,'lib'])
if libpath not in sys.path:
    sys.path.insert(0,libpath)

class HttpHandler(BaseHTTPRequestHandler):
    logger=None
    hdrlog =None
    runcfg = None
    fDBReseting=False
    httpserver =None
    rootdir = None
    def __del__(self):
        #self.hdrlog.close()
        #print('end http server')
        pass





    def list_dir(self, path, related_path):
        """Helper to produce a directory listing (absent index.html).

        Return value is either a file object, or None (indicating an
        error).  In either case, the headers are sent, making the
        interface the same as for send_head().

        """
        content =""
        try:
            list = os.listdir(path)
        except os.error:
            self.send_error(404, "No permission to list directory")
            return ""
        list.sort(key=lambda a: a.lower())
        #f = StringIO()
        displaypath = cgi.escape(urllib.unquote(self.path))
        content='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'
        content+="<html>\n<title>Directory listing for %s</title>\n" % displaypath
        content+="<body>\n<h2>Directory listing for %s</h2>\n" % displaypath
        content+="<hr>\n<ul>\n"
        content+='''
        <SCRIPT>
    function post( id, script, dest )
        {
            element = document.getElementById(id);
            value = element.value
            params = 'script='+encodeURI(script)+'&arg='+encodeURI(value)
            var xmlhttp;

            if (window.XMLHttpRequest)
            {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp=new XMLHttpRequest();
            }
            else
            {// code for IE6, IE5
                xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
            }

            xmlhttp.onreadystatechange=function()
            {
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {
                    alert(xmlhttp.responseText);
                    newHTML( xmlhttp.responseText);
                    setTimeout("window.close()",3000);
                }
            }
            xmlhttp.open("POST",dest,true);
            xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
            xmlhttp.send( params );
        }
    function newHTML(HTMLstring) {
        //var checkitem = mygetCheckedItem();
        //HTMLstring=post( 'manualtest','/cgi-bin/onSUTLIST.py', 'bedname='+encodeURI(checkitem) );
        var newwindow=window.open();
        var newdocument=newwindow.document;
        newdocument.write(HTMLstring);
        newdocument.close();
    }
        </SCRIPT>
        '''
        for name in list:
            fullname = os.path.join(path, name)
            displayname = linkname = name
            # Append / for directories or @ for symbolic links
            if os.path.isdir(fullname):
{'fraction_non_alphanumeric': 0.12245567957977675, 'fraction_numerical': 0.009192383453709783, 'mean_word_length': 2.023821339950372, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 20}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1154188', 'n_tokens_mistral': 1826, 'n_tokens_neox': 1739, 'n_words': 411}