Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,17 +2,28 @@ import streamlit as st
|
|
| 2 |
import random
|
| 3 |
import time
|
| 4 |
import git
|
| 5 |
-
import os
|
| 6 |
from google.api_core.exceptions import InternalServerError
|
| 7 |
|
| 8 |
flag = False
|
| 9 |
repo = st.text_input(label="Paste the .git link of repository.")
|
| 10 |
btn = st.button(label="Submit")
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
def clone_repo(repo):
|
| 13 |
if os.path.exists("githubCode") and os.path.isdir("githubCode"):
|
| 14 |
print("File already exists!!")
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
else:
|
| 17 |
print("Cloning repo!!")
|
| 18 |
git.Repo.clone_from(repo,"githubCode")
|
|
|
|
| 2 |
import random
|
| 3 |
import time
|
| 4 |
import git
|
| 5 |
+
import os, shutil, stat
|
| 6 |
from google.api_core.exceptions import InternalServerError
|
| 7 |
|
| 8 |
flag = False
|
| 9 |
repo = st.text_input(label="Paste the .git link of repository.")
|
| 10 |
btn = st.button(label="Submit")
|
| 11 |
|
| 12 |
+
def rm_dir_readonly(func, path, _):
|
| 13 |
+
os.chmod(path, stat.S_IWRITE)
|
| 14 |
+
func(path)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
def clone_repo(repo):
|
| 18 |
if os.path.exists("githubCode") and os.path.isdir("githubCode"):
|
| 19 |
print("File already exists!!")
|
| 20 |
+
shutil.rmtree('githubCode', onerror=rm_dir_readonly)
|
| 21 |
+
print("cleaning and cloning repo")
|
| 22 |
+
git.Repo.clone_from(repo,"githubCode")
|
| 23 |
+
|
| 24 |
+
with open("Code.txt", "r+", encoding="utf-8") as output:
|
| 25 |
+
output.truncate(0)
|
| 26 |
+
output.seek(0)
|
| 27 |
else:
|
| 28 |
print("Cloning repo!!")
|
| 29 |
git.Repo.clone_from(repo,"githubCode")
|