Example #1
0
    def __init__(self, config):
        """
        :param config: API configuration
        :type config: dict
        """

        self.cmd = Commands(self, config)
        self.last_update_id = ''
        self.token = config['telegram_token']
        self.api_link = config['telegram_api_link']
        self.api_host = config['telegram_api_host']
        self.commands = self.cmd.get_commands()
is_private = args.is_private
repo_kind = args.kind
repo_dir = args.dir

API_URL = "https://api.github.com"
REPO_PATH = "./Projects/MyLabs/"  # set your default folder

payload = json.dumps({"name": repo_name, "private": is_private})
headers = {
    "Authorization": "token " + USER_TOKEN,
    "Accept": "application/vnd.github.v3+json"
}

### Classes ###
# Command (kind, name, repo_path, repo_dir):
newCommands = Commands(repo_kind, repo_name, REPO_PATH, repo_dir)

# create repository
try:
    respons = requests.post(f"{API_URL}/user/repos",
                            data=payload,
                            headers=headers)
    respons.raise_for_status()
except requests.exceptions.RequestException as err:
    raise SystemExit(err)

# install on computer and upload
try:
    newCommands.create_dir_project()
    os.system(
        f"git clone https://{USER_TOKEN}@github.com/{USER_NAME}/{repo_name}.git"