Skip to content

Commit 382d440

Browse files
committed
Added CI workflow for linting and formatting checks
1 parent a3ac36d commit 382d440

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3491
-2545
lines changed

Jarvis.py

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,48 @@
55

66

77
def application():
8-
pages = {
9-
"": [
10-
st.Page("src/apps/public/home.py", title="Home", icon=":material/home:"),
11-
st.Page("src/apps/public/youtubePlaylist.py", title="Jarvis Videos", icon=":material/ondemand_video:"),
12-
],
13-
"Account": [
14-
st.Page("src/apps/auth/auth.py", title="Authentication", icon=":material/lock_open:"),
15-
],
16-
}
17-
18-
if st.user and st.user.is_logged_in:
19-
MAIN_DIR = "src/apps/pages"
20-
folders = getFolders(MAIN_DIR)
21-
if folders:
22-
for folder_name, folder_dir in folders.items():
23-
pages[folder_name.title()] = structPages(f"{MAIN_DIR}/{folder_dir}")
24-
25-
if st.user.email == st.secrets["general"]["ADMIN_EMAIL"] and st.user.given_name == st.secrets["general"]["ADMIN_NAME"]:
26-
pages.update({
27-
"Admin": [
28-
st.Page("src/apps/auth/env.py", title="Environment Variables", icon=":material/security:"),
29-
]
30-
})
31-
32-
return st.navigation(pages)
8+
pages = {
9+
"": [
10+
st.Page("src/apps/public/home.py", title="Home", icon=":material/home:"),
11+
st.Page(
12+
"src/apps/public/youtubePlaylist.py",
13+
title="Jarvis Videos",
14+
icon=":material/ondemand_video:",
15+
),
16+
],
17+
"Account": [
18+
st.Page(
19+
"src/apps/auth/auth.py",
20+
title="Authentication",
21+
icon=":material/lock_open:",
22+
),
23+
],
24+
}
25+
26+
if st.user and st.user.is_logged_in:
27+
MAIN_DIR = "src/apps/pages"
28+
folders = getFolders(MAIN_DIR)
29+
if folders:
30+
for folder_name, folder_dir in folders.items():
31+
pages[folder_name.title()] = structPages(f"{MAIN_DIR}/{folder_dir}")
32+
33+
if (
34+
st.user.email == st.secrets["general"]["ADMIN_EMAIL"]
35+
and st.user.given_name == st.secrets["general"]["ADMIN_NAME"]
36+
):
37+
pages.update(
38+
{
39+
"Admin": [
40+
st.Page(
41+
"src/apps/auth/env.py",
42+
title="Environment Variables",
43+
icon=":material/security:",
44+
),
45+
]
46+
}
47+
)
48+
49+
return st.navigation(pages)
50+
3351

3452
application().run()

src/apps/auth/auth.py

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,34 @@
88

99

1010
def unix_to_ist(timestamp):
11-
india_tz = pytz.timezone('Asia/Kolkata')
12-
format_str = '%I:%M:%S %p IST'
13-
return datetime.fromtimestamp(timestamp, pytz.utc).astimezone(india_tz).strftime(format_str)
11+
india_tz = pytz.timezone("Asia/Kolkata")
12+
format_str = "%I:%M:%S %p IST"
13+
return (
14+
datetime.fromtimestamp(timestamp, pytz.utc)
15+
.astimezone(india_tz)
16+
.strftime(format_str)
17+
)
18+
1419

1520
def auth():
16-
if st.user and not st.user.is_logged_in:
17-
st.title("🔐 Login Required")
18-
st.write("Please authenticate using your Google account to access your profile.")
19-
if st.button("🔓 Authenticate with Google"):
20-
st.login("google")
21-
22-
else:
23-
st.title(f"🙏 {GreetUser(st.user.given_name)}")
24-
st.success("Welcome to Jarvis AI Assistant!", icon="🤝")
25-
st.image(st.user.picture, caption=st.user.name)
26-
st.write("Email:", st.user.email)
27-
28-
if st.button("Log out"):
29-
st.toast(f"Goodbye, {st.user.name}! See you soon!", icon="🚪")
30-
sleep(2)
31-
st.logout()
21+
if st.user and not st.user.is_logged_in:
22+
st.title("🔐 Login Required")
23+
st.write(
24+
"Please authenticate using your Google account to access your profile."
25+
)
26+
if st.button("🔓 Authenticate with Google"):
27+
st.login("google")
28+
29+
else:
30+
st.title(f"🙏 {GreetUser(st.user.given_name)}")
31+
st.success("Welcome to Jarvis AI Assistant!", icon="🤝")
32+
st.image(st.user.picture, caption=st.user.name)
33+
st.write("Email:", st.user.email)
34+
35+
if st.button("Log out"):
36+
st.toast(f"Goodbye, {st.user.name}! See you soon!", icon="🚪")
37+
sleep(2)
38+
st.logout()
39+
3240

3341
auth()

src/apps/auth/env.py

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,34 @@
22

33

44
def displayStreamlitSecrets(data, prefix=""):
5-
for key, value in data.items():
6-
full_key = f"{prefix}{key}"
7-
if isinstance(value, dict):
8-
st.divider()
9-
st.markdown(f"**{full_key}/**")
10-
displayStreamlitSecrets(value, prefix=full_key + "/")
11-
else:
12-
st.text_input(label=key, value=str(value), disabled=True, key=full_key)
5+
for key, value in data.items():
6+
full_key = f"{prefix}{key}"
7+
if isinstance(value, dict):
8+
st.divider()
9+
st.markdown(f"**{full_key}/**")
10+
displayStreamlitSecrets(value, prefix=full_key + "/")
11+
else:
12+
st.text_input(label=key, value=str(value), disabled=True, key=full_key)
13+
1314

1415
def env():
15-
st.title("Environment Variables")
16-
st.markdown(
17-
"""
16+
st.title("Environment Variables")
17+
st.markdown(
18+
"""
1819
This page displays the environment variables used in the application.
1920
The values are hidden for security reasons.
2021
"""
21-
)
22-
if st.user.email == st.secrets["general"]["ADMIN_EMAIL"] and st.user.given_name == st.secrets["general"]["ADMIN_NAME"]:
23-
st.success("You are logged in as an admin.", icon="✅")
24-
displayStreamlitSecrets(st.secrets)
25-
else:
26-
st.warning("You are not authorized to view the environment variables.", icon="⚠️")
22+
)
23+
if (
24+
st.user.email == st.secrets["general"]["ADMIN_EMAIL"]
25+
and st.user.given_name == st.secrets["general"]["ADMIN_NAME"]
26+
):
27+
st.success("You are logged in as an admin.", icon="✅")
28+
displayStreamlitSecrets(st.secrets)
29+
else:
30+
st.warning(
31+
"You are not authorized to view the environment variables.", icon="⚠️"
32+
)
33+
2734

2835
env()

src/apps/pages/automations/Coding/github.py

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,72 @@ def createRepository(user):
1010
repo = user.create_repo(repoName)
1111
st.success(f"Repository '{repo.name}' created successfully!", icon="🎉")
1212

13+
1314
def listRepositories(user):
1415
repos = user.get_repos()
1516
st.toast("Your repositories!", icon="😀")
1617
for i, repo in enumerate(repos):
1718
st.info(f"{i+1}. {repo.name}")
1819

20+
1921
def createIssue(user):
20-
repoName = st.selectbox("Select the repository", [repo.name for repo in user.get_repos()])
22+
repoName = st.selectbox(
23+
"Select the repository", [repo.name for repo in user.get_repos()]
24+
)
2125
issueTitle = st.text_input("Enter the issue title")
2226
if st.button("Create Issue") and repoName != "" and issueTitle != "":
2327
repo = user.get_repo(repoName)
2428
issue = repo.create_issue(title=issueTitle)
25-
st.success(f"Issue '{issue.title}' created successfully in '{repo.name}' Repository!", icon="🎉")
29+
st.success(
30+
f"Issue '{issue.title}' created successfully in '{repo.name}' Repository!",
31+
icon="🎉",
32+
)
33+
2634

2735
def createPullRequest(user):
28-
repoName = st.selectbox("Select the repository", [repo.name for repo in user.get_repos()])
36+
repoName = st.selectbox(
37+
"Select the repository", [repo.name for repo in user.get_repos()]
38+
)
2939
title = st.text_input("Enter the pull request title")
3040
headBranch = st.text_input("Enter the head branch")
3141
baseBranch = st.text_input("Enter the base branch")
32-
if st.button("Create Pull Request") and repoName != "" and title != "" and headBranch != "" and baseBranch != "":
42+
if (
43+
st.button("Create Pull Request")
44+
and repoName != ""
45+
and title != ""
46+
and headBranch != ""
47+
and baseBranch != ""
48+
):
3349
repo = user.get_repo(repoName)
3450
head = f"{user.login}:{headBranch}"
3551
base = baseBranch
3652
pr = repo.create_pull(title=title, head=head, base=base)
37-
st.success(f"Pull request '{pr.title}' created successfully in '{repo.name}'!", icon="🎉")
53+
st.success(
54+
f"Pull request '{pr.title}' created successfully in '{repo.name}'!",
55+
icon="🎉",
56+
)
57+
3858

3959
def removeFiles():
4060
subprocess.run(["git", "reset"])
4161
st.toast("All files removed from the staging area successfully.", icon="🎉")
4262

63+
4364
def commitFiles():
44-
files = st.text_area("Enter the file names to commit (separated by commas)").split(",")
65+
files = st.text_area("Enter the file names to commit (separated by commas)").split(
66+
","
67+
)
4568
message = st.text_input("Enter the commit message")
4669
subprocess.run(["git", "add"] + files.split())
4770
subprocess.run(["git", "commit", "-m", message])
4871
st.toast("Files committed successfully!", icon="🎉")
4972

73+
5074
def pushCommits():
5175
subprocess.run(["git", "push"])
5276
st.toast("Commits pushed successfully!", icon="🎉")
5377

78+
5479
def restoreAllFiles():
5580
try:
5681
subprocess.run(["git", "restore", "--staged", "."])
@@ -59,6 +84,7 @@ def restoreAllFiles():
5984
except Exception as e:
6085
st.toast(f"Error occurred while restoring files: {str(e)}", icon="⚠️")
6186

87+
6288
def github():
6389
st.markdown("## Github Automation 🤖")
6490
access_token = st.text_input("Enter your Github access token")
@@ -67,7 +93,21 @@ def github():
6793
github = Github(access_token)
6894
user = github.get_user()
6995

70-
choice = st.selectbox("Select a task", [None, "Create Repository", "List Repositories", "Create Issue", "Create Pull Request", "Remove Files from Staging Area", "Commit Files", "Push Commits", "Restore all files from Staging Area"], key="github_choice")
96+
choice = st.selectbox(
97+
"Select a task",
98+
[
99+
None,
100+
"Create Repository",
101+
"List Repositories",
102+
"Create Issue",
103+
"Create Pull Request",
104+
"Remove Files from Staging Area",
105+
"Commit Files",
106+
"Push Commits",
107+
"Restore all files from Staging Area",
108+
],
109+
key="github_choice",
110+
)
71111

72112
if choice == "Create Repository":
73113
createRepository(user)

src/apps/pages/automations/Messenger/EMail.py

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,38 @@
55

66

77
def EMail():
8-
st.markdown("#### Welcome to E-mail Automation")
9-
senderEmail = st.text_input("Enter your E-mail Address")
10-
passWord = st.text_input("Enter your Password", type="password")
8+
st.markdown("#### Welcome to E-mail Automation")
9+
senderEmail = st.text_input("Enter your E-mail Address")
10+
passWord = st.text_input("Enter your Password", type="password")
1111

12-
receiverEmails = st.text_area("Enter the Recipient's E-mail Addresses (separated by commas)").split(",")
13-
message = MIMEText(st.text_area("Enter the body of the mail"))
14-
message['From'] = senderEmail
15-
message['To'] = ", ".join(receiverEmails)
16-
message['Subject'] = st.text_input("Enter the Subject of the mail", value="Automated Email")
12+
receiverEmails = st.text_area(
13+
"Enter the Recipient's E-mail Addresses (separated by commas)"
14+
).split(",")
15+
message = MIMEText(st.text_area("Enter the body of the mail"))
16+
message["From"] = senderEmail
17+
message["To"] = ", ".join(receiverEmails)
18+
message["Subject"] = st.text_input(
19+
"Enter the Subject of the mail", value="Automated Email"
20+
)
1721

18-
if st.button("Send Mail"):
19-
if senderEmail != "" and passWord != "" and receiverEmails != [] and message != "":
20-
receiverEmail = receiverEmail.strip()
21-
server = smtplib.SMTP('smtp.gmail.com', 587)
22-
server.ehlo()
23-
server.starttls()
24-
server.login(senderEmail, passWord)
25-
server.sendmail(senderEmail, receiverEmails, message.as_string())
26-
server.close()
27-
st.success(f"E-mail has sent successfully!", icon="✅")
28-
else:
29-
st.error("Please provide all the details.", icon="🚨")
30-
st.info(f'''Switch on the 'Less secure app access' of sender's mail by using this [link](https://myaccount.google.com/lesssecureapps?pli=1&rapt=AEjHL4MWL7anq0zxK7rt3arv3YBLKrAswWmAWqOkIUCd0qKKHlpQyezvEt2ruMNK2BaXddqMJlydydf-quRjLpwabeoLI_tZ3Q).''', icon="ℹ️")
22+
if st.button("Send Mail"):
23+
if (
24+
senderEmail != ""
25+
and passWord != ""
26+
and receiverEmails != []
27+
and message != ""
28+
):
29+
receiverEmail = receiverEmail.strip()
30+
server = smtplib.SMTP("smtp.gmail.com", 587)
31+
server.ehlo()
32+
server.starttls()
33+
server.login(senderEmail, passWord)
34+
server.sendmail(senderEmail, receiverEmails, message.as_string())
35+
server.close()
36+
st.success(f"E-mail has sent successfully!", icon="✅")
37+
else:
38+
st.error("Please provide all the details.", icon="🚨")
39+
st.info(
40+
f"""Switch on the 'Less secure app access' of sender's mail by using this [link](https://myaccount.google.com/lesssecureapps?pli=1&rapt=AEjHL4MWL7anq0zxK7rt3arv3YBLKrAswWmAWqOkIUCd0qKKHlpQyezvEt2ruMNK2BaXddqMJlydydf-quRjLpwabeoLI_tZ3Q).""",
41+
icon="ℹ️",
42+
)

0 commit comments

Comments
 (0)