-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathinit_connections.py
More file actions
49 lines (40 loc) · 2.01 KB
/
Copy pathinit_connections.py
File metadata and controls
49 lines (40 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from dotenv import load_dotenv
import os
from trello import create_oauth_token
load_dotenv()
gh_repo = os.getenv("GITHUB_REPO_URL")
gh_api_token_intern = os.getenv("GITHUB_TOKEN_INTERN")
gh_api_token_reviewer = os.getenv("GITHUB_TOKEN_REVIEWER")
openai_api_key = os.getenv("OPENAI_API_KEY")
trello_api_key = os.getenv("TRELLO_API_KEY")
trello_api_secret = os.getenv("TRELLO_API_SECRET")
trello_token = os.getenv("TRELLO_TOKEN")
trello_board_id = os.getenv("TRELLO_BOARD_ID")
if gh_repo is None:
gh_repo = input("Enter the GitHub repo URL: ")
if gh_api_token_intern is None:
gh_api_token_intern = input("Enter your GitHub Personnal Access token for the intern (https://github.com/settings/tokens): ")
if gh_api_token_reviewer is None:
gh_api_token_reviewer = input("Enter your GitHub Personnal Access token for the reviewer (https://github.com/settings/tokens): ")
if trello_api_key is None:
trello_api_key = input("Enter your Trello API key (https://trello.com/power-ups/admin): ")
if trello_api_secret is None:
trello_api_secret = input("Enter your Trello API secret (https://trello.com/power-ups/admin): ")
if trello_token is None:
auth_token = create_oauth_token(key=trello_api_key, secret=trello_api_secret, name='Trello API')
trello_token = auth_token['oauth_token']
if trello_board_id is None:
trello_board_id = input("Enter your Trello Board ID: ")
if openai_api_key is None:
openai_api_key = input("Enter your OpenAI API key (https://platform.openai.com/api-keys): ")
# Write them back to the .env file
with open(".env", "w") as f:
f.write(f"GITHUB_REPO_URL={gh_repo}\n")
f.write(f"GITHUB_TOKEN_INTERN={gh_api_token_intern}\n")
f.write(f"GITHUB_TOKEN_REVIEWER={gh_api_token_reviewer}\n")
f.write(f"OPENAI_API_KEY={openai_api_key}\n")
f.write(f"TRELLO_API_KEY={trello_api_key}\n")
f.write(f"TRELLO_API_SECRET={trello_api_secret}\n")
f.write(f"TRELLO_TOKEN={trello_token}\n")
f.write(f"TRELLO_BOARD_ID={trello_board_id}\n")
print("Environment variables set up successfully")