Update app.py
Browse files
app.py
CHANGED
@@ -31,7 +31,10 @@ def fetch_github_file(github_url, ssh_private_key):
|
|
31 |
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
32 |
|
33 |
# Load the private key
|
34 |
-
|
|
|
|
|
|
|
35 |
|
36 |
# Connect to GitHub using SSH
|
37 |
ssh.connect('github.com', username='git', pkey=private_key)
|
@@ -93,6 +96,8 @@ def process_input(file, github_url, ssh_private_key, gemini_api_key):
|
|
93 |
elif github_url and ssh_private_key:
|
94 |
if not ssh_private_key.strip():
|
95 |
return "Error: SSH Private Key is empty. Please provide a valid key."
|
|
|
|
|
96 |
try:
|
97 |
file_content = fetch_github_file(github_url, ssh_private_key)
|
98 |
if "error" in file_content:
|
@@ -114,7 +119,7 @@ iface = gr.Interface(
|
|
114 |
inputs=[
|
115 |
gr.File(label="Upload dependency file (e.g., requirements.txt, package.json, Gemfile)"),
|
116 |
gr.Textbox(label="GitHub Repository URL (optional, SSH or HTTPS format)"),
|
117 |
-
gr.
|
118 |
gr.Textbox(label="Gemini API Key", type="password"),
|
119 |
],
|
120 |
outputs=gr.Textbox(label="License Information and Analysis"),
|
|
|
31 |
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
32 |
|
33 |
# Load the private key
|
34 |
+
try:
|
35 |
+
private_key = paramiko.RSAKey.from_private_key(io.StringIO(ssh_private_key.strip()))
|
36 |
+
except paramiko.ssh_exception.SSHException as e:
|
37 |
+
return f"Error: Invalid SSH key - {str(e)}"
|
38 |
|
39 |
# Connect to GitHub using SSH
|
40 |
ssh.connect('github.com', username='git', pkey=private_key)
|
|
|
96 |
elif github_url and ssh_private_key:
|
97 |
if not ssh_private_key.strip():
|
98 |
return "Error: SSH Private Key is empty. Please provide a valid key."
|
99 |
+
if not ssh_private_key.strip().startswith("-----BEGIN"):
|
100 |
+
return "Error: Invalid SSH key format. Please ensure you've copied the entire key, including the BEGIN and END lines."
|
101 |
try:
|
102 |
file_content = fetch_github_file(github_url, ssh_private_key)
|
103 |
if "error" in file_content:
|
|
|
119 |
inputs=[
|
120 |
gr.File(label="Upload dependency file (e.g., requirements.txt, package.json, Gemfile)"),
|
121 |
gr.Textbox(label="GitHub Repository URL (optional, SSH or HTTPS format)"),
|
122 |
+
gr.Textarea(label="SSH Private Key (required if using GitHub URL)", lines=10),
|
123 |
gr.Textbox(label="Gemini API Key", type="password"),
|
124 |
],
|
125 |
outputs=gr.Textbox(label="License Information and Analysis"),
|