Ejemplo n.º 1
0
def bitbucketPr():
	# method with logic for the PR fetching
	team, username, password, repos = '', '', '', ''
	# inquiring user credentials
	while not username:
		username =  input("Please enter your BitBucket account username:"******"Please enter your BitBucket account email:")
	while not password:
		password =  input("Please enter your BitBucket account password:"******"Indicate either a reposiory or a list of repositories"+ \
								 "dividing each by space and press enter." + \
								 " Leave empty if you want to search in all team repositories:")
	
	# new instance of Authorisation class
	newAuth = Authorization(username, password, team, repos)

	links = [] 

	if not newAuth.repos: # method for handling no repo situationA
		links = newAuth.PrLinksNoRep()
		# handling PR's opening according to links' length
		if newAuth.CheckLinksLen(links) == True:  
			newAuth.openInBrowser(links)

		elif newAuth.CheckLinksLen(links) == False:
			print("")
			print("Two many pull requests. Try to filter by repository.")
			print("")
		elif newAuth.CheckLinksLen(links) == None:
			print("")
			print("Nothing was found. Try checking your credentials")
			print("")

	else: # if repo is specified
		links = newAuth.PRlinksWithRep()
		if newAuth.CheckLinksLen(links) == True:
			newAuth.openInBrowser(links)

		elif newAuth.CheckLinksLen(links) == False:
			print("")
			print('Two many PRs.')
			print('Opening 10 of them')
			print("*" *20)

			newAuth.openTenInBrowser(links)

		elif newAuth.CheckLinksLen(links) == None:
			print("")
			print("Nothing was found. Try checking your credentials")
			print("")
Ejemplo n.º 2
0
    def add_authorization(self, badge_id, person_email):
        """
        Add an authorization (allow someone to admin a certain badge)

        :type badge_id: str
        :param badge_id: ID of the badge

        :type person_email: str
        :param person_email: Email of the Person grant rights to
        """

        if self.person_exists(email=person_email) and \
           self.badge_exists(badge_id):

            person = self.get_person(person_email)

            new_authz = Authorization(badge_id=badge_id,
                                      person_id=person.id)
            self.session.add(new_authz)
            self.session.flush()

            return (person_email, badge_id)

        return False