Пример #1
0
    def test_update_url_strings(self):
        """
        Testing multiple `update` kwargs is may fail due to unordered
        dictionary keys
        """
        pv = Pivotal('ABCDEF', use_https=True)
        url = PROTO_SWITCH[True] + BASE_URL

        self.assertEqual(pv.projects('123').stories().add('story', name='New Story').url,
                url + 'projects/123/stories?story%5Bname%5D=New+Story')
        self.assertEqual(pv.projects('123').stories().update('story', name='New Story').url,
                url + 'projects/123/stories?story%5Bname%5D=New+Story')
        self.assertEqual(pv.projects('123').stories('456').update('story', name='Updated Story').url,
                url + 'projects/123/stories/456?story%5Bname%5D=Updated+Story')
        self.assertEqual(pv.projects('123').stories('456').tasks('789').update('task', description='count shields', priority=2, complete='false').url,
                url + 'projects/123/stories/456/tasks/789?task%5Bdescription%5D=count+shields&task%5Bcomplete%5D=false&task%5Bpriority%5D=2')
Пример #2
0
def get_stories_from_pt():
    stories = {}
    pt = Pivotal(environ.get('PT_TOKEN'))
    etree = pt.projects(environ.get('PT_PROJECT_ID')).stories().get_etree()
    for story in etree.findall('story'):
        sid = story.findtext('id')
        comments = []
        commits = []
        for note in story.findall('notes/note'):
            comment = note.findtext('text')
            comments.append(comment)
            commits.extend(git_commit_hash.findall(comment))
        s = {
            'story': story.findtext('name'),
            'state': story.findtext('current_state'),
            'comments': comments,
            'commits': commits
        }
        stories[sid] = s
    return stories
Пример #3
0
    def _test_url_strings(self, use_https):
        pv = Pivotal('ABCDEF', use_https=use_https)

        url = PROTO_SWITCH[use_https] + BASE_URL
        
        self.assertEqual(pv.projects().url, url + 'projects')
        self.assertEqual(pv.projects(123).url, url + 'projects/123')
        self.assertEqual(pv.projects('123').url, url + 'projects/123')
        self.assertEqual(pv.projects('123').stories().url, 
                      url + 'projects/123/stories')
        self.assertEqual(pv.projects('123').stories(filter='state:unstarted').url,
                      url + 'projects/123/stories?filter=state%3Aunstarted')

        self.assertEqual(pv.projects('123').stories('456').tasks().url,
                url + 'projects/123/stories/456/tasks')
        self.assertEqual(pv.projects('123').stories('456').tasks('789').url,
                url + 'projects/123/stories/456/tasks/789')
team = [
    {"email": "*****@*****.**", "token": "t0k3n"},
    # ...
]


def xml_get(node, field, default=""):
    try:
        return node.find(field).text
    except AttributeError:
        return ""


for person in team:
    pv = Pivotal(person["token"])

    data = {}

    xml = pv.projects().get_etree()
    for proj in xml.getchildren():
        proj_name = proj.find("name").text
        data[proj_name] = []
        id = int(proj.find("id").text)
        qs = {"filter": "state:started"}
        xml = pv.projects(id).stories(**qs).get_etree()
        for story in xml.getchildren():
            data[proj_name].append(
                {
                    "name": xml_get(story, "name"),
                    "url": xml_get(story, "url"),
Пример #5
0
def main(argv):
  defaults = {
    'name': DEFAULT_NAME,
    'description': DEFAULT_DESCRIPTION,
    'labels': DEFAULT_LABELS
  }
  piv = Pivotal(MY_TOKEN, PROJECT_ID, defaults)

  if len(argv) == 0:
    usage()
    sys.exit(2)

  command = argv[0]

  if command not in ('create', 'search'):
    usage()
    sys.exit(2)

  new_args = argv[1:]

  if command == 'create':
    try:
      opts, args = getopt.getopt(new_args, "t:n:l:", ["type=", "name=", "labels="])
    except getopt.GetoptError:
      usage()
      sys.exit(2)

    name = ''
    story_type = "feature"
    extra_labels = []

    for opt, arg in opts:
      if opt in ("-n", "--name"):
        name = arg
      elif opt in ("-t", "--type"):
        if arg in ("f", "feature"):
          story_type = "feature"
        elif arg in ("b", "bug"):
          story_type = "bug"
        elif arg in ("c", "chore"):
          story_type = "chore"
      elif opt in ("-l", "--labels"):
        extra_labels = re.findall(r'\w+', arg)

    if name == '':
      usage()
      sys.exit(2)

    story = piv.create(name, story_type, extra_labels)
    print storySummary(story)

  elif command == 'list':
    pass
    
  elif command == 'update':
    try:
      opts, args = getopt.getopt(new_args, "c:", ["comment="])
    except getopt.GetoptError:
      usage()
      sys.exit(2)

    for o, a in opts:
      if o in ("-c", "--comment"):
        pass

  elif command == 'search':
    try:
      opts, args = getopt.getopt(new_args, "l:", ["limit="])
    except getopt.GetoptError:
      usage()
      sys.exit(2)

    limit = 99
    for opt, arg in opts:
      if opt in ("-l", "--limit"):
        limit = int(arg)

    search = " ".join(args)
    matches = piv.search(search)
    for match in matches[:limit]:
      print storySummary(match)
Пример #6
0
# EndConfig

token_path = expanduser(token_file)

if not pivotal_token:
    try:
        pivotal_token = file(token_path).readlines()[0]
    except:
        sys.exit(
            "Pivotal Tracker token not specified.\n \
            Add to the script or create in ~/.pivotal_token"
        )

boolmap = {"true": True, "false": False}

pv = Pivotal(pivotal_token)

##############################################################################
# Find all projects and create a dictionary of basic project info
##############################################################################
projects = {}
project_choices = []

_projects = pv.projects().get_etree().findall("project")
for pos, project in enumerate(_projects):
    pid = project.find("id").text
    pname = project.find("name").text
    use_https = boolmap[project.find("use_https").text]
    labels = project.find("labels").text.split(",")
    projects[pos + 1] = {"id": pid, "name": pname, "use_https": use_https, "labels": labels}
    project_choices.append("[%d] %s" % (pos + 1, pname))
Пример #7
0

# Planning Board Lists
# {u'pos': 16384, u'idBoard': u'34sdw9576fee44f982b0009ec', u'id': u'34sd9576fee44f982b0009ed', u'closed': False, u'name': u'Next Up'}
# {u'pos': 32768, u'idBoard': u'34sdw9576fee44f982b0009ec', u'id': u'34sd9576fee44f982b0009ee', u'closed': False, u'name': u'Spec'}
# {u'pos': 49152, u'idBoard': u'34sdw9576fee44f982b0009ec', u'id': u'34sd9576fee44f982b0009ef', u'closed': False, u'name': u'Design'}
# {u'pos': 115712, u'idBoard': u'34sdw9576fee44f982b0009ec', u'id': u'34sd95be04bf835957000b42', u'closed': False, u'name': u'Ready'}

# Current development Board Lists
# {u'pos': 9216, u'idBoard': u'34sdw427a6320f450000d4d', u'id': u'34sdw935eae09f8c03200048e', u'closed': False, u'name': u'Next Up'}
# {u'pos': 16384, u'idBoard': u'34sdw427a6320f450000d4d', u'id': u'34sdw93427a6320f450000d4e', u'closed': False, u'name': u'In Progress'}
# {u'pos': 32768, u'idBoard': u'34sdw427a6320f450000d4d', u'id': u'34sdw93427a6320f450000d4f', u'closed': False, u'name': u'QA'}
# {u'pos': 49152, u'idBoard': u'34sdw427a6320f450000d4d', u'id': u'34sdw93427a6320f450000d50', u'closed': False, u'name': u'Launchpad'}
# {u'pos': 115712, u'idBoard': u'34sdw427a6320f450000d4d', u'id': u'34sdw938e4571979847000d64', u'closed': False, u'name': u'Live'}

pivotal = Pivotal()
trello = Trello()

# unscheduled 32162031

movements = {
    'icebox_bugs': {'target': bugs_inbox_id, 'filters': {'filter': 'type:bug state:unscheduled'}},
    'icebox_features': {'target': planning_nextup_id, 'filters': {'filter': 'type:feature,chore state:unscheduled', 'limit': '10', 'offset': '76'}},
    'current_nextup': {'target': current_nextup_id, 'filters': {'filter': 'state:unstarted', 'limit': '30', 'offset': '10'}},
    'current_inprogress': {'target': current_inprogress_id, 'filters': {'filter': 'state:started'}},
    'current_qa': {'target': current_qa_id, 'filters': {'filter': 'state:finished'}},
    'current_live': {'target': current_live_id, 'filters': {'filter': 'state:delivered', 'limit': '30', 'offset': '7'}},
    'current_inprogress2': {'target': current_inprogress_id, 'filters': {'filter': 'state:rejected'}},
    # 'icebox_features': {'target': planning_nextup_id, 'filters': {'filter': 'id:43068683,41430591,33693103,33691827,32161881,37317209'}}
    # 'icebox_bugs': {'target': bugs_inbox_id, 'filters': {'filter': 'id:41753701,38746909'}}
}
Пример #8
0
import tornado.web

import json

from pivotal import Pivotal

#
# set up interface to Pivotal
#
token = os.getenv('PIVOTAL_TOKEN')
if not token:
    msg = 'Please provide your Pivotal API token via an environment variable: PIVOTAL_TOKEN\n' \
          'Your API Token can be found on your Profile page: https://www.pivotaltracker.com/profile'
    raise RuntimeError(msg)

pivotal = Pivotal(project='1885757', token=token)


class GitHubHandler(tornado.web.RequestHandler):
    def get(self):
        """
        Receive and process a message from GitHub
        """
        self.write("Well, Hello there!")

    def post(self):
        """
        Receive and process a message from GitHub
        """
        print('--------------------------------------')
        print('POST received:', self.request.headers.get('X-GitHub-Event'))