Exemple #1
0
    def initialize_github(self):
        """Initialize github data.
        """
        configuration = self.git.get_configuration("github")
        token = configuration.get("token")

        if token and not self.namespace.new:
            token = prompt(MESSAGES["github_token"], token)
        else:
            user = prompt(MESSAGES["github_user"], configuration.get("user"))
            password = prompt(MESSAGES["github_password"], echo=False)
            name = "continuity:{0}".format(self.git.repo.working_dir)
            url = "https://github.com/jzempel/continuity"

            try:
                token = GitHubService.create_token(user, password, name,
                        url=url)
            except GitHubRequestException:
                code = prompt(MESSAGES["github_2fa_code"])
                token = GitHubService.create_token(user, password, name,
                        code=code, url=url)

            if not token:
                exit("Invalid GitHub credentials.")

        return {"token": token}
Exemple #2
0
    def initialize_github(self):
        """Initialize github data.
        """
        configuration = self.git.get_configuration("github")
        token = configuration.get("oauth-token")

        if token and not self.namespace.new:
            token = prompt("GitHub OAuth token", token)
        else:
            user = prompt("GitHub user", configuration.get("user"))
            password = getpass("GitHub password: "******"continuity:{0}".format(self.git.repo.working_dir)
            url = "https://github.com/jzempel/continuity"
            token = GitHubService.create_token(user, password, name, url)

            if not token:
                exit("Invalid GitHub credentials.")

        return {"oauth-token": token}