コード例 #1
0
ファイル: loader.py プロジェクト: u-u-h/adpc
    def loadTestSuites(self, filename='test.conf'):
        p = config.Parser(filename)
        (ts, df, defs) = p.parse()
        ts_dict = dict()
        self.stack = []

        debug('Defaults:')
        debug(defs)

        l = zip(ts, defs)
        for i in ts:
            if self.testMethodPrefix == 'gen':
                ts_name = 'Generate state: ' + i.value
            else:
                ts_name = i.value
            self.testsuite_name = i.name
            self.testsuite = self.suiteClass((), ts_name)
            ts_dict[i.name] = self.testsuite
            self.print_ts(i)
        return (defs, ts_dict)
コード例 #2
0
#!/usr/bin/python
# -*- coding: ISO-8859-1 -*-

__version__ = "0.0.4"

#########
# History
# v0.0.4

import CGIHTTPServer, SocketServer, BaseHTTPServer
import os, sys, time, socket

import config

cfg = config.Parser()

cfg.set_section("Server")
ListenPort = cfg.get("ListenPort", "int")
LogFile = os.path.join(os.getcwd(), cfg.get("LogFile"))
AllowIPs = cfg.get("AllowIPs")
AllowIPs = AllowIPs.split(",")
AllowIPs = [IP.strip() for IP in AllowIPs]


class RedirectStdOut:
    def __init__(self, File, stdoutObj):
        self.MyStdOut = stdoutObj
        self.File = File

    def write(self, *txt):
        txt = " ".join([str(i) for i in txt])
コード例 #3
0
def start_module( selfURL ):

    print "Content-Type: text/html\n\n"

    ## Konfiguration lesen
    cfg = config.Parser()
    cfg.set_section("console")
    maxHistoryLines         = cfg.get( "maxHistoryLines", "int" )
    forceHTMLCompression    = cfg.get( "forceCompression" )

    # Breite der Eingabe Zeile
    input_size              = cfg.get( "input size", "int" )

    # Standartd Timeout in sek für jeden Befehl
    process_timeout         = cfg.get( "process timeout", "int" )

    # ZusatzInfornationen Anzeigen
    verbose                 = cfg.get( "verbose", "boolean" )



    #~ MyOut = CompressedOut.AutoCompressedOut( forceHTMLCompression )
    #~ print "<!-- Out-Compression:'%s' -->" % MyOut.get_mode()
    #~ for i in os.environ: print i,os.environ[i],"<br>"



    # HTML-Pre Ausgeben
    print htmlPre % {
        "charset"       : locale.getdefaultlocale()[1],
        "uname"         : os.uname()
    }




    if CGIdata.has_key("stdout"):
        # Alte Ausgaben wieder anzeigen
        txt = CGIdata["stdout"]
        compressLen = len( txt )
        txt = decompress( txt )  # Ausgaben dekomprimieren

        decompressLen = len( txt )
        MyOutConverter.put_data( txt )
        print txt.replace( "\n", "<br>\n" )
    else:
        compressLen = 0
        decompressLen = 0
        txt = ""


    ## Alte Verzeichnis wieder herstellen
    if CGIdata.has_key("current_dir") and os.path.isdir( CGIdata["current_dir"] ):
        current_dir = CGIdata["current_dir"]
        # Ins alte Verzeichnis wechseln
        os.chdir( current_dir )
    else:
        current_dir = os.getcwd()


    ## Process Timeout Lesen und Anzeigen
    if CGIdata.has_key("timeout"):
        process_timeout = int( CGIdata["timeout"] )


    ## Befehl Ausführen
    if CGIdata.has_key("cmd"):
        command = CGIdata["cmd"]
        # Prompt mit Befehl anzeigen
        prompt = "<p><strong>%s>%s</strong></p>\n" % (current_dir, command)
        print prompt
        # Prompt auch in die History speichern
        MyOutConverter.put_data( prompt )

        print "<p><small>Process Timeout: %dsec.</small></p>" % process_timeout

        if command.startswith("cd "):
            # Verzeichnis wechsel
            destination_dir = command[3:]
            destination_dir = os.path.join( current_dir, destination_dir )
            destination_dir = os.path.normpath( destination_dir )
            if os.path.isdir( destination_dir ):
                # Neuer Zielpfad existiert
                current_dir = destination_dir
            else:
                print "Directory [%s] does not exists<br>" % destination_dir
        else:
            # Befehl ausführen
            cmd( command, current_dir, process_timeout )

    # Neues, aktuelles Prompt anzeigen
    print "<strong>%s&gt;</strong>" % current_dir

    # Ausgaben kürzen und Komprimieren, damit der Client weniger Daten wieder zurück senden muß
    # Die Kompression zahlt sich nach zwei, drei Befehlen i.d.R. aus...
    stdout_raw = compress( cutLines( MyOutConverter.get_data(), maxHistoryLines ) )
    #~ stdout_raw = MyOutConverter.get_data()

    if verbose:
        print "<p><small>compress: %d  decompress: %d<br />" % (compressLen, decompressLen)
        print "(console - 'verbose mode')</small></p>"


    print htmlPost % {
        "self"              : selfURL,
        "stdout_raw"        : stdout_raw,
        "current_dir"       : current_dir,
        "input_size"        : input_size,
        "process_timeout"   : str( process_timeout )
        }
コード例 #4
0
                        help="Gerrit user",
                        dest="user",
                        action="store")

    parser.add_argument("-p",
                        "--password",
                        help="Gerrit password",
                        dest="password",
                        action="store")

    parser.add_argument(
        "-d",
        "--duration",
        help="Test duration in seconds",
        dest="duration",
        action="store",
        type=int,
    )

    parser.add_argument("-c",
                        "--config",
                        help="Configuration file",
                        dest="config_file",
                        action="store")

    args = parser.parse_args()

    test = LoadTestInstance(config.Parser(args).parse())
    test.prerun()
    test.run()
コード例 #5
0
 def read_config(self):
     "Server Konfiguration lesen"
     cfg = config.Parser()
     cfg.set_section("Server")
     self.AllowIPs = cfg.get("AllowIPs", "list")
     self.AllowModules = cfg.get("AllowModules", "list")