fcakyon commited on
Commit
b180c60
1 Parent(s): 1a27e7d
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import shutil
3
+ from pathlib import Path
4
+ from urllib.parse import urlparse
5
+
6
+ os.system("pip install GitPython")
7
+
8
+ from git import Repo
9
+
10
+ token = os.getenv('GH_TOKEN')
11
+ repo_url = os.getenv('REPO')
12
+
13
+ REPO_URL, BRANCH_NAME = repo_url.split('@')
14
+ OWNER_REPO_NAME = urlparse(REPO_URL).path.lstrip("/")
15
+ REPO_DIR_NAME = Path(urlparse(REPO_URL).path).stem
16
+
17
+ Repo.clone_from(f"https://{token}@github.com/{OWNER_REPO_NAME}", REPO_DIR_NAME, branch=BRANCH_NAME)
18
+
19
+ for item in Path(REPO_DIR_NAME).iterdir():
20
+ shutil.copytree(item, Path.cwd() / item.name, dirs_exist_ok=True) if item.is_dir() else shutil.copy2(item, Path.cwd())
21
+
22
+ def del_error_handler(func, path, exc_info):
23
+ if not os.access(path, os.W_OK):
24
+ os.chmod(path, 0o600)
25
+ func(path)
26
+ else:
27
+ raise
28
+ shutil.rmtree(REPO_DIR_NAME, onerror=del_error_handler)
29
+
30
+ os.system("pip install -r requirements.txt")
31
+
32
+ from gradio_app import demo
33
+
34
+ demo.queue(concurrency_count=3).launch()