示例#1
0
def main():

    wsOpts = WSOpts()
    parser = wsOpts.get_common_opts()

    parser.add_option("--from_stream",
                      dest="fromStream",
                      help="get states from from this stream")
    parser.add_option(
        "--to_stream",
        dest="toStream",
        help=
        "update triage in this stream\n\t\tSpecial stream name Every_stream reserved for all stream update"
    )

    (options, args) = parser.parse_args()
    wsOpts.setLogging(options.debug)

    if wsOpts.checkRequiredMissing(options, ('fromStream', 'toStream')):
        parser.print_help()
        sys.exit(-1)

    configServiceClient = ConfigServiceClient(options)
    streamFromDO = configServiceClient.get_stream(options.fromStream)
    streamToDO = configServiceClient.get_stream(options.toStream)

    defectServiceClient = DefectServiceClient(options)

    defects_done = 0
    batch = 200
    matching_cids = []
    # Fetch the set of defects to copy triage from
    mergedDefectDOs = defectServiceClient.get_merged_defects(
        streamFromDO, statusFilter='all')
    TotalCids = mergedDefectDOs.totalNumberOfRecords
    if TotalCids < 0:
        logging.error("Error!  Failed to get Merged Defects to copy from!")
        sys.exit(-1)
    matching_cids = [d.cid for d in mergedDefectDOs.mergedDefects]
    if TotalCids != len(matching_cids):
        logging.error(
            "Should not happen: length of matching_cids isn't same as TotalCids"
        )
    while defects_done < TotalCids:
        logging.debug("Got %d of %d total MDs" % (defects_done, TotalCids))
        defectServiceClient.copy_triage(matching_cids[defects_done::batch],
                                        streamFromDO, streamToDO)
        defects_done += batch
        logging.debug("Got %d of %d total MDs" %
                      (min(defects_done, TotalCids), TotalCids))
    logging.info("Copied triage for %d defects" % (TotalCids))
示例#2
0
def main():

    wsOpts = WSOpts()
    parser = wsOpts.get_common_opts()

    parser.add_option("--from_stream",  dest="fromStream",  help="get states from from this stream")
    parser.add_option("--to_stream",    dest="toStream",  help="update triage in this stream\n\t\tSpecial stream name Every_stream reserved for all stream update")

    (options, args) = parser.parse_args()
    wsOpts.setLogging(options.debug)

    if wsOpts.checkRequiredMissing(options, ('fromStream','toStream')):
        parser.print_help()
        sys.exit(-1)

    configServiceClient = ConfigServiceClient(options)
    streamFromDO = configServiceClient.get_stream(options.fromStream)
    streamToDO = configServiceClient.get_stream(options.toStream)

    defectServiceClient = DefectServiceClient(options)

    defects_done = 0
    batch = 200
    matching_cids = []
    # Fetch the set of defects to copy triage from
    mergedDefectDOs = defectServiceClient.get_merged_defects(streamFromDO, statusFilter='all')
    TotalCids = mergedDefectDOs.totalNumberOfRecords
    if TotalCids < 0:
        logging.error("Error!  Failed to get Merged Defects to copy from!")
        sys.exit(-1)
    matching_cids = [d.cid for d in mergedDefectDOs.mergedDefects]
    if TotalCids != len(matching_cids):
        logging.error("Should not happen: length of matching_cids isn't same as TotalCids")
    while defects_done < TotalCids:
        logging.debug("Got %d of %d total MDs" % (defects_done, TotalCids))
        defectServiceClient.copy_triage(matching_cids[defects_done::batch], streamFromDO, streamToDO)
        defects_done += batch
        logging.debug("Got %d of %d total MDs" % (min(defects_done,TotalCids), TotalCids))
    logging.info("Copied triage for %d defects" % (TotalCids))
示例#3
0
def main():
    wsOpts = WSOpts()
    parser = wsOpts.get_common_opts()

    (options, args) = parser.parse_args()

    if wsOpts.checkRequiredMissing(options, ('stream', )):
        parser.print_help()
        sys.exit(-1)

    wsOpts.setLogging(options.debug)

    configServiceClient = ConfigServiceClient(options)
    defectServiceClient = DefectServiceClient(options)

    streamIdDO = configServiceClient.get_stream(options.stream)

    mergedDefectDOs = defectServiceClient.get_merged_defects(
        streamIdDO, statusFilter='all')
    total = mergedDefectDOs.totalNumberOfRecords
    logging.debug(total)
    if total < 1:
        logging.warning("No defects")
        sys.exit(1)

    mdDOs = mergedDefectDOs.mergedDefects
    got = len(mergedDefectDOs.mergedDefects)

    attrlist = [
        'mergeKey', 'classification', 'severity', 'action', 'comment',
        'filePathname', 'functionDisplayName'
    ]
    cidlist = []
    logging.debug("Got " + str(len(mdDOs)) + " out of " + str(total) +
                  " defects")
    for md in mdDOs:
        ciddict = {}
        logging.debug("Cid %d, status %s, %s mergeKey" %
                      (md.cid, md.status, md.mergeKey))
        for attr in attrlist:
            ciddict[attr] = getattr(md, attr, None)
            logging.debug(ciddict[attr])
        cidlist.append(ciddict)

    logging.debug("Exporting " + str(len(cidlist)) + " defects")
    Writer = csv.DictWriter(open("keysTriage.csv", 'wb'), attrlist)
    Writer.writerow(dict((fn, fn) for fn in attrlist))
    for z in cidlist:
        logging.debug("CID " + str(z['mergeKey']) + ": " +
                      str(z['classification']))
        Writer.writerow(z)
示例#4
0
def main():
    wsOpts = WSOpts()
    parser = wsOpts.get_common_opts()

    (options, args) = parser.parse_args()

    if wsOpts.checkRequiredMissing(options, ('stream', )):
        parser.print_help()
        sys.exit(-1)

    wsOpts.setLogging(options.debug)

    configServiceClient = ConfigServiceClient(options)
    defectServiceClient = DefectServiceClient(options)

    streamIdDO = configServiceClient.get_stream(options.stream)

    mergedDefectDOs = defectServiceClient.get_merged_defects(
        streamIdDO, statusFilter='all')
    logging.debug(mergedDefectDOs.totalNumberOfRecords)
    total = mergedDefectDOs.totalNumberOfRecords
    if total < 1:
        logging.warning("No defects")
        sys.exit(1)

    mdDOs = mergedDefectDOs.mergedDefects
    got = len(mergedDefectDOs.mergedDefects)

    cidlist = []
    ciddict = {}
    logging.debug("Got " + str(len(mdDOs)) + " out of " + str(total) +
                  " defects")
    for md in mdDOs:
        occurrences = defectServiceClient.get_num_stream_defect_occurrences(
            md.cid, options.stream)
        logging.debug("Cid %d, status %s, %d occurrences" %
                      (md.cid, md.status, occurrences))
        cidlist.append((md.cid, md.classification, max(1, occurrences)))

    totals = sum(x[2] for x in cidlist)
    print "Total occurrences:", totals
    ones = len(set(y[0] for y in cidlist if y[2] == 1))
    moreThanOne = ((y[0], y[2]) for y in cidlist if y[2] > 1)

    logging.debug(str(ones) + " defects have one occurrence")
    if ones < totals:
        logging.debug("The following " + str(len(set(moreThanOne))) +
                      " defects have more than one occurrence")
        for z in sorted(moreThanOne):
            logging.debug("CID " + str(z[0]) + ": " + str(z[1]))
示例#5
0
def main():
    wsOpts = WSOpts()
    parser = wsOpts.get_common_opts()

    (options, args) = parser.parse_args()
    wsOpts.setLogging(options.debug)

    if wsOpts.checkRequiredMissing(options, ('snapshot',)):
        parser.print_help()
        sys.exit(-1)

    configServiceClient = ConfigServiceClient(options)
    defectServiceClient = DefectServiceClient(options)

    snapshotIdDO = configServiceClient.get_snapshot(options.snapshot)
    if not snapshotIdDO:
        logging.error("No valid snapshot found")
        parser.print_help()
        sys.exit(-1)

    streamname = configServiceClient.get_stream_by_snapshot(options.snapshot)
    streamIdDOs = configServiceClient.get_stream(streamname)
    if not streamIdDOs:
        logging.error("No valid stream for this snapshot found")
        sys.exit(-1)
    if len(streamIdDOs) != 1:
        logging.error("Found more than one stream for this snapshot!!!")
        sys.exit(-1)
    streamIdDO = streamIdDOs[0]

    try:
        md = defectServiceClient.get_merged_defects_by_snapshot(snapshotIdDO,streamIdDO)
    except:
        logging.warning("No merged defects for snapshot found")
        sys.exit(-1)
    try:
        cids = [d.cid for d in md.mergedDefects]
    except:
        logging.error("Error getting cids for snapshot")
        sys.exit(-1)

    totalFetched = len(cids)
    if totalFetched < 1:
        print "No defects in snapshot", snapshotIdDO.id.snapshotId.id
        sys.exit(1)
    else:
        print "Fetched "+ str(totalFetched) + " cids in snapshot", options.snapshot
示例#6
0
def main():
    wsOpts = WSOpts()
    parser = wsOpts.get_common_opts()
    parser.add_option("--file",
                      dest="filename",
                      help="Limit defects to those in file <filename>")

    (options, args) = parser.parse_args()
    wsOpts.setLogging(options.debug)

    if wsOpts.checkRequiredMissing(options, ('stream', )):
        parser.print_help()
        sys.exit(-1)

    configServiceClient = ConfigServiceClient(options)
    defectServiceClient = DefectServiceClient(options)

    streamIdDO = configServiceClient.get_stream(options.stream)

    mergedDefectDOs = defectServiceClient.get_merged_defects(
        streamIdDO, statusFilter='New', filename=options.filename)
    total = mergedDefectDOs.totalNumberOfRecords
    if total < 1:
        logging.warning("No new defects")
        sys.exit(1)

    mdDOs = mergedDefectDOs.mergedDefects

    cidlist = []
    for md in mdDOs:
        occurrences = defectServiceClient.get_stream_defect_occurrences(
            md.cid, options.stream)
        logging.debug("CID %d, status %s, %d occurrences" %
                      (md.cid, md.status, len(occurrences)))
        cidlist.append((md.cid, md.classification, max(1, len(occurrences))))

    totals = sum(x[2] for x in cidlist)
    print "Total occurrences:", totals
    ones = len(set(y[0] for y in cidlist if y[2] == 1))
    moreThanOne = ((y[0], y[2]) for y in cidlist if y[2] > 1)

    print ones, " defects have one occurrence"
    if ones < totals:
        print "The following defects have more than one occurrence"
        for z in sorted(moreThanOne):
            print "CID ", z[0], ": ", z[1]
def main():
    wsOpts = WSOpts()
    parser = wsOpts.get_common_opts()

    (options, args) = parser.parse_args()

    if wsOpts.checkRequiredMissing(options, ('stream',)):
        parser.print_help()
        sys.exit(-1)

    wsOpts.setLogging(options.debug)

    configServiceClient = ConfigServiceClient(options)
    defectServiceClient = DefectServiceClient(options)

    streamIdDO = configServiceClient.get_stream(options.stream)

    mergedDefectDOs = defectServiceClient.get_merged_defects(streamIdDO, statusFilter='all')
    logging.debug(mergedDefectDOs.totalNumberOfRecords)
    total = mergedDefectDOs.totalNumberOfRecords
    if total < 1:
        logging.warning("No defects")
        sys.exit(1)

    mdDOs = mergedDefectDOs.mergedDefects
    got = len(mergedDefectDOs.mergedDefects)

    cidlist = []
    ciddict = {}
    logging.debug("Got "+str(len(mdDOs))+" out of "+str(total)+" defects")
    for md in mdDOs:
        occurrences = defectServiceClient.get_num_stream_defect_occurrences(md.cid, options.stream)
        logging.debug("Cid %d, status %s, %d occurrences" % (md.cid, md.status, occurrences))
        cidlist.append((md.cid, md.classification, max(1,occurrences)))

    totals = sum(x[2] for x in cidlist)
    print "Total occurrences:", totals
    ones = len(set(y[0] for y in cidlist if y[2] == 1))
    moreThanOne = ( (y[0],y[2]) for y in cidlist if y[2] > 1)

    logging.debug( str(ones) + " defects have one occurrence")
    if ones < totals:
        logging.debug("The following " + str(len(set(moreThanOne))) + " defects have more than one occurrence")
        for z in sorted(moreThanOne):
            logging.debug("CID " + str(z[0]) + ": " + str(z[1]))
def main():
    wsOpts = WSOpts()
    parser = wsOpts.get_common_opts()

    (options, args) = parser.parse_args()

    if wsOpts.checkRequiredMissing(options, ('stream',)):
        parser.print_help()
        sys.exit(-1)

    wsOpts.setLogging(options.debug)

    configServiceClient = ConfigServiceClient(options)
    defectServiceClient = DefectServiceClient(options)

    streamIdDO = configServiceClient.get_stream(options.stream)

    mergedDefectDOs = defectServiceClient.get_merged_defects(streamIdDO, statusFilter='all')
    total = mergedDefectDOs.totalNumberOfRecords
    logging.debug(total)
    if total < 1:
        logging.warning("No defects")
        sys.exit(1)

    mdDOs = mergedDefectDOs.mergedDefects
    got = len(mergedDefectDOs.mergedDefects)

    attrlist = ['mergeKey','classification','severity','action','comment','filePathname','functionDisplayName']
    cidlist = []
    logging.debug("Got "+str(len(mdDOs))+" out of "+str(total)+" defects")
    for md in mdDOs:
        ciddict = {}
        logging.debug("Cid %d, status %s, %s mergeKey" % (md.cid, md.status, md.mergeKey))
        for attr in attrlist:
            ciddict[attr]=getattr(md,attr,None)
            logging.debug(ciddict[attr])
        cidlist.append(ciddict)

    logging.debug("Exporting " + str(len(cidlist)) + " defects")
    Writer = csv.DictWriter(open("keysTriage.csv",'wb'), attrlist)
    Writer.writerow(dict((fn,fn) for fn in attrlist))
    for z in cidlist:
         logging.debug("CID " + str(z['mergeKey']) + ": " + str(z['classification']))
         Writer.writerow(z)
示例#9
0
def main():
    wsOpts = WSOpts()
    parser = wsOpts.get_common_opts()
    parser.add_option("--file",  dest="filename",  help="Limit defects to those in file <filename>")

    (options, args) = parser.parse_args()
    wsOpts.setLogging(options.debug)

    if wsOpts.checkRequiredMissing(options, ('stream',)):
        parser.print_help()
        sys.exit(-1)

    configServiceClient = ConfigServiceClient(options)
    defectServiceClient = DefectServiceClient(options)

    streamIdDO = configServiceClient.get_stream(options.stream)

    mergedDefectDOs = defectServiceClient.get_merged_defects(streamIdDO, statusFilter='New', filename=options.filename)
    total = mergedDefectDOs.totalNumberOfRecords
    if total < 1:
        logging.warning("No new defects")
        sys.exit(1)

    mdDOs = mergedDefectDOs.mergedDefects

    cidlist = []
    for md in mdDOs:
        occurrences = defectServiceClient.get_stream_defect_occurrences(md.cid, options.stream)
        logging.debug("CID %d, status %s, %d occurrences" % (md.cid, md.status, len(occurrences)))
        cidlist.append((md.cid, md.classification, max(1,len(occurrences))))

    totals = sum(x[2] for x in cidlist)
    print "Total occurrences:", totals
    ones = len(set(y[0] for y in cidlist if y[2] == 1))
    moreThanOne = ( (y[0],y[2]) for y in cidlist if y[2] > 1)

    print ones, " defects have one occurrence"
    if ones < totals:
        print "The following defects have more than one occurrence"
        for z in sorted(moreThanOne):
            print "CID ", z[0], ": ", z[1]
示例#10
0
def main():
    wsOpts = WSOpts()
    parser = wsOpts.get_common_opts()
    parser.add_option("--user1", dest="user1", help="Owner of defects")
    parser.add_option("--user2", dest="user2", help="New owner to assign defects to")

    (options, args) = parser.parse_args()
    wsOpts.setLogging(options.debug)

    if wsOpts.checkRequiredMissing(options, ('user1','user2')):
        parser.print_help()
        sys.exit(-1)

    if options.user1 == options.user2:
        logging.warning("Users are the same.  Nothing to do")
        sys.exit(0)

    configServiceClient = ConfigServiceClient(options)
    defectServiceClient = DefectServiceClient(options)

    streamIdDO = configServiceClient.get_stream(options.stream)

    mergedDefectDOs = defectServiceClient.get_merged_defects(streamIdDO, users=options.user1,statusFilter='all')
    logging.debug(mergedDefectDOs.totalNumberOfRecords)
    total = mergedDefectDOs.totalNumberOfRecords
    if total < 1:
        logging.warning("No defects returned")
        sys.exit(1)

    mdDOs = mergedDefectDOs.mergedDefects
    got = len(mergedDefectDOs.mergedDefects)

    logging.debug("Length of list %d %d" % (got, total))
    cidlist = []
    for md in mdDOs:
        cidlist.append(md.cid)

    scope = defectServiceClient.set_scope(options.project, options.stream)
    logging.debug("Setting %d defects to owner=%s in scope %s" % (len(cidlist), options.user2, scope))
    defectServiceClient.update_merged_defect(cidlist, scope, owner=options.user2)
示例#11
0
def main():
    wsOpts = WSOpts()
    parser = wsOpts.get_common_opts()

    (options, args) = parser.parse_args()
    wsOpts.setLogging(options.debug)

    if wsOpts.checkRequiredMissing(options, ('snapshot', )):
        parser.print_help()
        sys.exit(-1)

    configServiceClient = ConfigServiceClient(options)
    defectServiceClient = DefectServiceClient(options)

    snapshotIdDO = configServiceClient.get_snapshot(options.snapshot)
    snapshotInfoDO = configServiceClient.get_snapshot_info(options.snapshot)

    if not snapshotInfoDO:
        logging.warning("No valid snapshot found")
        parser.print_help()
        sys.exit(-1)
    streamname = configServiceClient.get_stream_by_snapshot(options.snapshot)
    streamIdDOs = configServiceClient.get_stream(streamname)
    if not streamIdDOs:
        logging.error("No valid stream for this snapshot found")
        parser.print_help()
        sys.exit(-1)
    if len(streamIdDOs) != 1:
        logging.error("Found more than one stream for this snapshot!!!")
        parser.print_help()
        sys.exit(-1)
    streamIdDO = streamIdDOs[0]

    lastSnapshotIdDO = configServiceClient.get_snapshot_by_date(
        datetime.datetime.now(), streamIdDO)
    logging.debug("Last snapshot in stream %s is " % (streamIdDO.name))
    logging.debug(lastSnapshotIdDO.id.snapshotId.id)

    mergedDefectDOs = defectServiceClient.get_merged_defects_by_snapshot(
        snapshotIdDO, streamIdDO)
    logging.debug("Last snapshot in this stream is " +
                  str(lastSnapshotIdDO.id.snapshotId.id))

    totalFetched = mergedDefectDOs.totalNumberOfRecords
    if totalFetched < 1:
        logging.warning("No defects")
        sys.exit(1)
    else:
        logging.debug(
            str(totalFetched) + " merged defects fetched for snapshot " +
            str(snapshotIdDO.id) + " " + streamIdDO.name)
        pass

    currentMDDOs = defectServiceClient.get_merged_defects(streamIdDOs, 'all')
    if currentMDDOs.totalNumberOfRecords < 1:
        logging.warning("Something is wrong: no current defects")
        sys.exit(1)
    cids = [md.cid for md in currentMDDOs.mergedDefects]
    logging.debug(len(cids))
    badcids = ([
        md.cid for md in mergedDefectDOs.mergedDefects if md.cid not in cids
    ])
    goodcids = ([
        md.cid for md in mergedDefectDOs.mergedDefects if md.cid in cids
    ])
    allcids = [md.cid for md in mergedDefectDOs.mergedDefects]
    logging.debug(len(allcids))
    logging.debug(len(set(cids).difference(set(allcids))))
    logging.debug(len(set(allcids).difference(set(cids))))
    mds = ([md for md in mergedDefectDOs.mergedDefects if md.cid in cids])
    logging.info(str(len(cids)) + " cids were committed - " + str(len(mds)))
    # things to add
    # get previous snapshot CIDs, compare
    # get next snapshot CIDs, compare
    # give breakdown of CIDs in that snapshot by current status
    print "Number of CIDs committed to stream %s in snapshot %s: %d " % (
        streamname, options.snapshot, len(cids))
    print " of which:"
    Fixed = [md.cid for md in mds if md.status == 'Fixed']
    Dismissed = [md.cid for md in mds if md.status == 'Dismissed']
    Triaged = [md.cid for md in mds if md.status == 'Triaged']
    New = [md.cid for md in mds if md.status == 'New']
    print len(Fixed), " were fixed"
    print len(Dismissed), " are dismissed"
    print len(Triaged), " were triaged but still outstanding"
    print len(New), " are still New and untriaged"
def main():
    wsOpts = WSOpts()
    parser = wsOpts.get_common_opts()

    (options, args) = parser.parse_args()
    wsOpts.setLogging(options.debug)

    if wsOpts.checkRequiredMissing(options, ('snapshot',)):
        parser.print_help()
        sys.exit(-1)

    configServiceClient = ConfigServiceClient(options)
    defectServiceClient = DefectServiceClient(options);

    snapshotIdDO = configServiceClient.get_snapshot(options.snapshot)
    snapshotInfoDO = configServiceClient.get_snapshot_info(options.snapshot)

    if not snapshotInfoDO:
        logging.warning("No valid snapshot found")
        parser.print_help()
        sys.exit(-1)
    streamname = configServiceClient.get_stream_by_snapshot(options.snapshot)
    streamIdDOs = configServiceClient.get_stream(streamname)
    if not streamIdDOs:
        logging.error("No valid stream for this snapshot found")
        parser.print_help()
        sys.exit(-1)
    if len(streamIdDOs) != 1:
        logging.error("Found more than one stream for this snapshot!!!")
        parser.print_help()
        sys.exit(-1)
    streamIdDO = streamIdDOs[0]

    lastSnapshotIdDO = configServiceClient.get_snapshot_by_date(datetime.datetime.now(), streamIdDO)
    logging.debug("Last snapshot in stream %s is " % (streamIdDO.name))
    logging.debug(lastSnapshotIdDO.id.snapshotId.id)

    mergedDefectDOs = defectServiceClient.get_merged_defects_by_snapshot(snapshotIdDO, streamIdDO)
    logging.debug("Last snapshot in this stream is " + str(lastSnapshotIdDO.id.snapshotId.id))

    totalFetched = mergedDefectDOs.totalNumberOfRecords
    if totalFetched < 1:
        logging.warning("No defects")
        sys.exit(1)
    else:
        logging.debug(str(totalFetched) + " merged defects fetched for snapshot " + str(snapshotIdDO.id) + " " + streamIdDO.name)
        pass

    currentMDDOs = defectServiceClient.get_merged_defects(streamIdDOs, 'all')
    if currentMDDOs.totalNumberOfRecords < 1:
        logging.warning("Something is wrong: no current defects")
        sys.exit(1)
    cids = [md.cid for md in currentMDDOs.mergedDefects]
    logging.debug(len(cids))
    badcids =  ([md.cid for md in mergedDefectDOs.mergedDefects if md.cid not in cids])
    goodcids =  ([md.cid for md in mergedDefectDOs.mergedDefects if md.cid in cids])
    allcids =  [md.cid for md in mergedDefectDOs.mergedDefects]
    logging.debug(len(allcids))
    logging.debug(len(set(cids).difference(set(allcids))))
    logging.debug(len(set(allcids).difference(set(cids))))
    mds =  ([md for md in mergedDefectDOs.mergedDefects if md.cid in cids])
    logging.info(str(len(cids)) + " cids were committed - " + str(len(mds)))
    # things to add
    # get previous snapshot CIDs, compare
    # get next snapshot CIDs, compare
    # give breakdown of CIDs in that snapshot by current status
    print "Number of CIDs committed to stream %s in snapshot %s: %d " % (streamname,options.snapshot,len(cids))
    print " of which:"
    Fixed = [md.cid for md in mds if md.status=='Fixed']
    Dismissed = [md.cid for md in mds if md.status=='Dismissed']
    Triaged = [md.cid for md in mds if md.status=='Triaged']
    New = [md.cid for md in mds if md.status=='New']
    print len(Fixed), " were fixed"
    print len(Dismissed), " are dismissed"
    print len(Triaged), " were triaged but still outstanding"
    print len(New), " are still New and untriaged"