Ejemplo n.º 1
0
def main():
    """
    the main entry point
    """
    (s, args) = create_suite(sys.argv[1:])
    if not s.config.quiet:
        classic_display(s, sys.stdout)

    args = expandvars(args)
    args = group_brackets(args)
    tf = tparser_factory(args, s)
    tests = tf.get_tests()
    s.event['test_added'].publish(gantlet.events.test_added_event, len(tests))

    if s.config.xmlout:
        xml_display(s, open(s.config.xmlout, 'w'))

    if s.config.email:
        email_display(s, s.config.email, s.config.smtpserver)

    if s.config.gui:
        gui = gui_display(s)
        gui.root.after(1000, runall, s, tests)
        gui.root.mainloop()
    else:
        runall(s, tests)

    errcode = s.tot_tests_broken + s.tot_tests_failed
    if errcode:
        sys.stderr.write( \
            "Error: gantlet: %d failed tests and %d broken tests.\n"% \
            ( s.tot_tests_failed, s.tot_tests_broken ) )
        sys.exit(errcode)
    return
Ejemplo n.º 2
0
def main():
    """
    the main entry point
    """
    (s, args) = create_suite( sys.argv[1:] )
    if not s.config.quiet:
        classic_display( s, sys.stdout )

    args = expandvars( args )
    args = group_brackets( args )        
    tf = tparser_factory( args, s )
    tests = tf.get_tests()
    s.event['test_added'].publish( gantlet.events.test_added_event, len(tests) )
    
    if s.config.xmlout :
        xml_display( s, open( s.config.xmlout,'w' ) )

    if s.config.email :
        email_display(s, s.config.email, s.config.smtpserver )

    if s.config.gui :
        gui = gui_display( s )
        gui.root.after( 1000, runall, s, tests )
        gui.root.mainloop()
    else:
        runall( s, tests )

    errcode = s.tot_tests_broken + s.tot_tests_failed
    if errcode:
        sys.stderr.write( \
            "Error: gantlet: %d failed tests and %d broken tests.\n"% \
            ( s.tot_tests_failed, s.tot_tests_broken ) )
        sys.exit( errcode )
    return
Ejemplo n.º 3
0
def _test():
    verbose=0
    repository = "."
    output = "index.html"
    display=['session','profile','hostname','date','time','path']
    sort=['session','profile']
    breakon='package'
    email=None
    mailserver=None
    selectdate=None
    selectpackage=".*"
    selectprofile=".*"
    selectsession=".*"
    selects=[]
    (opts,args)=getopt.getopt(sys.argv[1:],shortopts,longopts)
    for (o,v) in opts:
        if o in ("-h","--help"):
            print(help_string)
            sys.exit(0)
        elif o in ("-v", "--verbose"):
            verbose=1
        elif o in ("-r","--repository"):
            repository=v
        elif o in ("-o","--output"):
            output=v
        elif o in ("-d","--display"):
            display=v.split(',')
        elif o in ("-s","--sort-order"):
            sort=v.split(',')
        elif o in ("-b","--break-tables-on"):
            breakon=v
        elif o in ("-e","--email"):
            email=v
        elif o in ("-m","--mailserver"):
            mailserver=v
        elif o in ("-b","--break-tables-on"):
            breakon=v
        elif o in ("-t","--today"):
            selectdate="24 hours"
        elif o in ("-l","--select"):
            selects = v.split(',')
            for s in selects:
                (x,y)=s.split('=')
                if x == "package":
                    selectpackage=y
                elif x == "profile":
                    selectprofile=y
                elif x == "session":
                    selectsession=y
                elif x == "date":
                    selectdate=y
                else:
                    print( "Unrecognized select option:", x)

    mgr = session_archiver( repository )
    daterange = parse_date(selectdate)
    msgs = mgr.select(package=selectpackage,profile=selectprofile,
                      session=selectsession,
                      starttime=daterange[0], endtime=daterange[1])
    f = open(output,'w')
    viewer = html_viewer(break_tables_on=breakon,
                         display_order=display,
                         sort_order=sort
                         )
    viewer.html_page( f, msgs )
    f.close()
    
    if not( email == None or mailserver == None):
        f = open(output,'r')
        e = email_display( None, email, mailserver)
        msg = MIMEText(f.read(), "html", "iso-8859-1")
        msg["Precedence"] = "bulk"
        e.verbose = verbose
        whoami = 'unknown'
        try:
            whoami = os.getlogin()
        except:
            pass
        hostname = socket.getfqdn()
        email_from = whoami + "@" + hostname
        date = rfc822time()
        subject="Gantlet Results"
        msg["To"] = email
        msg["From"] = email_from
        msg["Subject"] = "Gantlet Results"
        e.email_to_SMTP(msg)

    f.close()
Ejemplo n.º 4
0
def _test():
    verbose=0
    repository = "."
    output = "index.html"
    display=['session','profile','hostname','date','time','path']
    sort=['session','profile']
    breakon='package'
    email=None
    mailserver=None
    selectdate=None
    selectpackage=".*"
    selectprofile=".*"
    selectsession=".*"
    selects=[]
    (opts,args)=getopt.getopt(sys.argv[1:],shortopts,longopts)
    for (o,v) in opts:
        if o in ("-h","--help"):
            print help_string
            sys.exit(0)
        elif o in ("-v", "--verbose"):
            verbose=1
        elif o in ("-r","--repository"):
            repository=v
        elif o in ("-o","--output"):
            output=v
        elif o in ("-d","--display"):
            display=v.split(',')
        elif o in ("-s","--sort-order"):
            sort=v.split(',')
        elif o in ("-b","--break-tables-on"):
            breakon=v
        elif o in ("-e","--email"):
            email=v
        elif o in ("-m","--mailserver"):
            mailserver=v
        elif o in ("-b","--break-tables-on"):
            breakon=v
        elif o in ("-t","--today"):
            selectdate="24 hours"
        elif o in ("-l","--select"):
            selects = v.split(',')
            for s in selects:
                (x,y)=s.split('=')
                if x == "package":
                    selectpackage=y
                elif x == "profile":
                    selectprofile=y
                elif x == "session":
                    selectsession=y
                elif x == "date":
                    selectdate=y
                else:
                    print "Unrecognized select option:", x

    mgr = session_archiver( repository )
    daterange = parse_date(selectdate)
    msgs = mgr.select(package=selectpackage,profile=selectprofile,
                      session=selectsession,
                      starttime=daterange[0], endtime=daterange[1])
    f = open(output,'w')
    viewer = html_viewer(break_tables_on=breakon,
                         display_order=display,
                         sort_order=sort
                         )
    viewer.html_page( f, msgs )
    f.close()
    
    if not( email == None or mailserver == None):
        f = open(output,'r')
        e = email_display( None, email, mailserver)
        e.file = f
        e.verbose = verbose
        whoami = 'unknown'
        try:
            whoami = os.getlogin()
        except:
            pass
        hostname = socket.getfqdn()
        email_from = whoami + "@" + hostname
        date = rfc822time()
        subject="Gantlet Results"
        header=std_header %( email_from, email, date, subject )
        e.email_from = email_from
        e.email_to = email
        e.email_file_via_SMTP(header)

    f.close()