def write_gdoc_results(doc=None, results=[]):
    print "Writing test results to %s" % doc
    doc = Spreadsheet(doc=doc)
    for result in results:
        props = {}
        props.update(result['criteria'])
        props.update(result['results'])
        doc.append_row(props)
def write_gdoc_results(doc=None, results=[]):
    log.info("Writing test results to {url}".format(url=doc))
    doc = Spreadsheet(doc=doc)
    for result in results:
        props = {}
        props.update(result['criteria'])
        props.update(result['results'])
        doc.append_row(props)
def write_gdoc_results(doc=None, results=[]):
    log.info("Writing test results to {url}".format(url=doc))
    doc = Spreadsheet(doc=doc)
    for result in results:
        props = {}
        props.update(result['criteria'])
        props.update(result['results'])
        doc.append_row(props)
Example #4
0
def update_gdoc_spec(doc=None, spec=None):
    log.info("Updating test specs with latest CentralNotice changes... {url}".
             format(url=doc))

    # FIXME: currently, the spec must have been read with read_gdoc_spec in order to get row numbers
    if not spec:
        spec = read_gdoc_spec(doc=doc)

    spec.update_from_logs()

    doc = Spreadsheet(doc=doc)
    for index, test in enumerate(spec.spec, 0):
        api_rownum = index + 1
        rownum = index + 2
        if api_rownum < doc.num_rows():
            if not hasattr(test, 'modified') or not test.modified:
                continue
            log.debug("updating spec end time in row {rownum}: {spec}".format(
                rownum=rownum, spec=test))
            if test.end_time:
                doc.update_row({'end': test.end_time}, index=api_rownum)
        else:
            log.debug("appending spec row {rownum}: {spec}".format(
                rownum=rownum, spec=test))
            doc.append_row({
                'label': test.label,
                'type': "banner",
                'start': test.start_time,
                'end': test.end_time,
                'campaign': test.campaign['name'],
                'banners': ", ".join(test.banners),
            })
def update_gdoc_spec(doc=None, spec=None):
    print "Updating test specs with latest CentralNotice changes... ", doc

    # FIXME: currently, the spec must have been read with read_gdoc_spec in order to get row numbers
    if not spec:
        spec = read_gdoc_spec(doc=doc)

    spec.update_from_logs()

    doc = Spreadsheet(doc=doc)
    for index, test in enumerate(spec.spec, 0):
        test = spec.spec[index]
        rownum = index + 1
        if rownum < doc.num_rows():
            if not hasattr(test, 'modified') or not test.modified:
                continue
            print("DEBUG: updating spec end time in row %d" % rownum, test)
            if test.end_time:
                doc.update_row({'end': test.end_time}, index=rownum)
        else:
            print("DEBUG: appending spec row (%d)" % index, test)
            doc.append_row({
                'label': test.label,
                'type': "banner",
                'start': test.start_time,
                'end': test.end_time,
                'campaign': test.campaign['name'],
                'banners': ", ".join(test.banners),
            })
Example #6
0
def update_gdoc_spec(doc=None, spec=None):
    log.info("Updating test specs with latest CentralNotice changes... {url}".format(url=doc))

    # FIXME: currently, the spec must have been read with read_gdoc_spec in order to get row numbers
    if not spec:
        spec = read_gdoc_spec(doc=doc)

    spec.update_from_logs()

    doc = Spreadsheet(doc=doc)
    for index, test in enumerate(spec.spec, 0):
        api_rownum = index + 1
        rownum = index + 2
        if api_rownum < doc.num_rows():
            if not hasattr(test, 'modified') or not test.modified:
                continue
            log.debug("updating spec end time in row {rownum}: {spec}".format(rownum=rownum, spec=test))
            if test.end_time:
                doc.update_row({'end': test.end_time}, index=api_rownum)
        else:
            log.debug("appending spec row {rownum}: {spec}".format(rownum=rownum, spec=test))
            doc.append_row({
                'label': test.label,
                'type': "banner",
                'start': test.start_time,
                'end': test.end_time,
                'campaign': test.campaign['name'],
                'banners': ", ".join(test.banners),
            })
def update_gdoc_results(doc=None, results=[]):
    log.info("Updating results in {url}".format(url=doc))
    doc = Spreadsheet(doc=doc)
    existing = list(doc.get_all_rows())

    def find_matching_cases(criteria):
        matching = []

        def fuzzy_compare_row(row, criteria):
            if not row:
                return False
            if criteria['banner'] == row['banner'] and criteria[
                    'campaign'] == row['campaign'] and criteria[
                        'start'] == row['start']:
                return True

        for n, row in enumerate(existing, 1):
            if fuzzy_compare_row(row, criteria):
                matching.append(n)

        return matching

    for result in results:
        if not result:
            continue

        matching = find_matching_cases(result['criteria'])

        props = {}
        props.update(result['results'])
        props.update(result['criteria'])

        if len(matching) == 0:
            doc.append_row(props)
        else:
            if len(matching) > 1:
                log.warn(
                    "more than one result row {match} matches criteria: {criteria}"
                    .format(match=matching, criteria=result['criteria']))
            index = matching[-1]
            log.debug("updating row {rownum} with {banner}".format(
                rownum=index, banner=result['criteria']['banner']))
            doc.update_row(props, index=index)
def update_gdoc_results(doc=None, results=[]):
    print "Updating results in %s" % doc
    doc = Spreadsheet(doc=doc)
    existing = list(doc.get_all_rows())

    def find_matching_cases(criteria):
        matching = []

        def fuzzy_compare_row(row, criteria):
            if not row:
                return False
            if criteria['banner'] == row['banner'] and criteria['campaign'] == row['campaign'] and criteria['start'] == row['start']:
                return True

        for n, row in enumerate(existing, 1):
            if fuzzy_compare_row(row, criteria):
                matching.append(n)

        return matching

    for result in results:
        if not result:
            continue

        matching = find_matching_cases(result['criteria'])

        props = {}
        props.update(result['results'])
        props.update(result['criteria'])

        if len(matching) == 0:
            doc.append_row(props)
        else:
            if len(matching) > 1:
                print "WARNING: more than one result row %s matches criteria: %s" % (matching, result['criteria'], )
            index = matching[-1]
            print "DEBUG: updating row %d with %s" % (index, result['criteria']['banner'])
            doc.update_row(props, index=index)
def update_gdoc_results(doc=None, results=[]):
    log.info("Updating results in {url}".format(url=doc))
    doc = Spreadsheet(doc=doc)
    existing = list(doc.get_all_rows())

    def find_matching_cases(criteria):
        matching = []

        def fuzzy_compare_row(row, criteria):
            if not row:
                return False
            if criteria['banner'] == row['banner'] and criteria['campaign'] == row['campaign'] and criteria['start'] == row['start']:
                return True

        for n, row in enumerate(existing, 1):
            if fuzzy_compare_row(row, criteria):
                matching.append(n)

        return matching

    for result in results:
        if not result:
            continue

        matching = find_matching_cases(result['criteria'])

        props = {}
        props.update(result['results'])
        props.update(result['criteria'])

        if len(matching) == 0:
            doc.append_row(props)
        else:
            if len(matching) > 1:
                log.warn("more than one result row {match} matches criteria: {criteria}".format(match=matching, criteria=result['criteria']))
            index = matching[-1]
            log.debug("updating row {rownum} with {banner}".format(rownum=index, banner=result['criteria']['banner']))
            doc.update_row(props, index=index)
Example #10
0
def read_gdoc_spec(doc=None):
    rows = list(Spreadsheet(doc=doc).get_all_rows())
    return FrTestSpec(spec=list(parse_spec(rows)))