Пример #1
0
def __main__():
    parser = argparse.ArgumentParser(
        description=u"Check CoreJet report against PivotalTracker")
    parser.add_argument(
        "sections", nargs="?",
        help=(u"comma separated list of pivotal.cfg section names to "
              u"retrieve epics from"))
    parser.add_argument(
        "--token",
        help=u"default pivotal token to use to authenticate")
    parser.add_argument(
        "--project",
        help=u"default pivotal project id to retrieve stories from")
    parser.add_argument(
        metavar="corejet.xml", dest="filename", nargs="?",
        default="parts/test/corejet/corejet.xml",
        help=(u"path to CoreJet test report "
              u"(defaults to parts/test/corejet/corejet.xml)"))

    args = parser.parse_args()

    defaults = {
        "project": args.project,
        "token": args.token
    }
    defaults = config.read("defaults", defaults)

    sections = None
    if args.sections:
        sections = [name.strip() for name in args.sections.split(",")]
    if not sections and "epics" in defaults:
        sections = [name.strip() for name in defaults["epics"].split(",")]

    epics = {}
    if sections:
        for section in sections:
            epics[section] = config.read(section, defaults)

    if None in defaults.values():
        parser = argparse.ArgumentParser(
            description=u"Check CoreJet report against PivotalTracker")
        parser.add_argument(
            "--token", required=True,
            help=u"pivotal token to use to authenticate")
        parser.add_argument(
            "--project", required=True,
            help=u"pivotal project id to retrieve stories from")
        parser.add_argument(
            metavar="parts/test/corejet/corejet.xml", dest="filename",
            help=u"path to CoreJet test report")
        args = parser.parse_args()

    corejet_etree = etree.fromstring(open(args.filename).read())
    if not sections:
        for epic in corejet_etree.findall("epic"):
            doPivotal(defaults, epic)
    for epic in epics:
        doPivotal(epics[epic], corejet_etree.find("epic[@id='%s']" % epic))
Пример #2
0
    )
)

# Response contains the http response
# Content contains the xml string
response, content = new_story.post()

if response["status"] != "200":
    print "There was an error adding the story"
    print "Status Code: %s" % response["status"]
    for error in content.findall("error"):
        print error.text
    sys.exit("Bye!")


_story = etree.fromstring(content)
story_id = _story.find("id").text
print "Added new story #%s" % story_id


##############################################################################
# Update the story using PUT
##############################################################################
story = pv.projects(project["id"]).stories(story_id).update("story", description="Bar should have plenty of whiskey")
response, content = story.put()

if response["status"] == "200":
    print "Story #%s updated successfully" % story_id
else:

    print "There was an error updating the story"