Esempio n. 1
0
def run_suite(scriptpath):

    tree = et()
    tree.parse(scriptpath)
    titer = tree.iter()

    config = get_config()

    suites = []
    cases = []
    errors = dict()
    last_tag = dict()
    case = ""
    for elem in titer:

        if elem.tag == "Suite":
            continue

        if elem.tag == "Case":
            case  = elem.get('name')
            log_line ("Use Case : '%s'"  % case)
            cases.append(case)
            errors[case] = 0
            result = 0
            continue

        if result == 0:
            tag_func = get_tag(elem.tag)
            if not tag_func:
                log_line ("Tag '%s' not found. Exiting."  % elem.tag)
                sys.exit(1)

            result = tag_func.run(elem, config)
            if result != 0:
                log_result (elem.tag, get_string_from_il_enum(result, "OMX_Error"))
                errors[case] = result
            last_tag[case] = elem.tag

    if result != 0:
        config.base_profile_mgr.stop()

    log_line()
    log_line()
    log_line("-------------------------------------------------------------------")
    msg = "SUITE EXECUTION SUMMARY : " + str(len(cases)) + " test cases executed"
    log_result (msg, get_string_from_il_enum(result, "OMX_Error"))
    last_error = 0
    for case in cases:
        msg = "CASE : " + case + " (last tag was '" + last_tag[case] + "')"
        log_result (msg, get_string_from_il_enum(errors[case], "OMX_Error"))
        if errors[case] != 0:
            last_error = errors[case]
    log_line()
    log_line("-------------------------------------------------------------------")
    log_line()

    return last_error
Esempio n. 2
0
def get_episodes(category):
    """
    Get a list of episodes in a given category.

    Returns:
        list of episodes
    """
    feed_url = FEEDS[category]['url']
    xmlfile = urllib2.urlopen(feed_url)
    tree = et(file=xmlfile)
    root = tree.getroot()
    channel = root[0]
    items = channel.findall('item')
    episodes = [get_episode_info(i, category) for i in items]
    return episodes
Esempio n. 3
0
def run_suite(scriptpath):

    tree = et()
    tree.parse(scriptpath)
    titer = tree.iter()

    config = get_config()

    suites = []
    cases = []
    errors = dict()
    last_tag = dict()
    case = ""
    for elem in titer:

        if elem.tag == "Suite":
            continue

        if elem.tag == "Case":
            case = elem.get('name')
            log_line("Use Case : '%s'" % case)
            cases.append(case)
            errors[case] = 0
            result = 0
            continue

        if result == 0:
            tag_func = get_tag(elem.tag)
            if not tag_func:
                log_line("Tag '%s' not found. Exiting." % elem.tag)
                sys.exit(1)

            result = tag_func.run(elem, config)
            if result != 0:
                log_result(elem.tag,
                           get_string_from_il_enum(result, "OMX_Error"))
                errors[case] = result
            last_tag[case] = elem.tag
Esempio n. 4
0
def MakePlots(pf, fn, prefix, deliverator):
    """
    This is the simplest way I can think of to do this.  We can get basically
    everything we need from the EnzoHippo instance.

    @param pf: EnzoStaticOutput instance
    @param fn: the XML file we're going to interpret to get
                           plot-info
    @param prefix: image file prefix
    @todo: Add "center" argument
    """
    pi = et(file=fn)
    r = pi.getroot()
    bn = pf.basename
    dx = pf.h.get_smallest_dx()
    for plot in r.getchildren():
        # Now we have a plot type, so let's get going, peoples!
        if plot.attrib.has_key("mindx"):
            mindx = float(plot.attrib["mindx"])
        else:
            mindx = 10  # 10 cells by default
        fields = []
        widths = []
        for fe in plot.findall("field"):
            fields.append(fe.text)
        for wi in plot.findall("width"):
            #print wi.text, wi.attrib["unit"]
            widths.append((float(wi.text), \
                           wi.attrib["unit"]))
        #print "widths:", widths
        plotType = plot.tag.lower()
        prefixDict = {'bn': bn, 'type': plotType}
        # Note that we never set fields in here, as the save takes care
        # of that.
        if plotType == "slice":
            pc = PlotCollection(pf, deliverator)
            f = 0
            center = None
            if plot.attrib.has_key("center"):
                center = map(float(plot.attrib["center"].split()))
            for field in fields:
                if f == 0:
                    pc.add_slice(field, 0, center=center)
                    pc.add_slice(field, 1, center=center)
                    pc.add_slice(field, 2, center=center)
                else:
                    for plot in pc.plots:
                        plot.switch_z(field)
                f += 1
                for width, unit in widths:
                    if (width / pf[unit] < mindx * dx):
                        #print "char:", width/pf[unit]
                        #print "morechar:",  mindx*dx, mindx, dx
                        continue
                    pc.set_width(width, unit)
                    prefixDict['width'] = width
                    prefixDict['unit'] = unit
                    pc.save(prefix % prefixDict, "png")
        elif plotType == "phase":
            for width, unit in widths:
                pc = PlotCollection(pf, deliverator)
                if (width / pf[unit] < mindx * dx):
                    continue
                prefixDict['width'] = width
                prefixDict['unit'] = unit
                #print fields, width, unit
                pc.add_phase_sphere(width, unit, fields)
                pc.save(prefix % prefixDict, "png")
        elif plotType == "proj":
            pc = PlotCollection(pf, deliverator)
            for fe in plot.findall("field"):
                field = fe.text
                weight = None
                if fe.attrib.has_key("weight"):
                    weight = fe.attrib["weight"]
                pc.add_projection(field, 0, weight_field=weight)
                pc.add_projection(field, 1, weight_field=weight)
                pc.add_projection(field, 2, weight_field=weight)
                for width, unit in widths:
                    if (width / pf[unit] < mindx * dx):
                        continue
                    prefixDict['width'] = width
                    prefixDict['unit'] = unit
                    pc.set_width(width, unit)
                    pc.save(prefix % prefixDict, "png")