HOPStudio commited on
Commit
c8588cb
·
verified ·
1 Parent(s): 7c85f70

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +12 -2
main.py CHANGED
@@ -53,10 +53,20 @@ def start_gradio():
53
 
54
  # 使用 git clone 下载指定仓库
55
  def clone_repository():
56
- destination_path = "/root"
57
  repo_url = "https://hf-mirror.com/HOPStudio/modelscope"
58
- clone_command = f"git clone {repo_url} {destination_path}"
 
 
 
 
 
 
 
 
59
 
 
 
60
  try:
61
  # 使用 subprocess 调用 git clone
62
  subprocess.run(clone_command, shell=True, check=True)
 
53
 
54
  # 使用 git clone 下载指定仓库
55
  def clone_repository():
56
+ destination_path = "/root/modelscope" # 更改目标路径为 /root/modelscope
57
  repo_url = "https://hf-mirror.com/HOPStudio/modelscope"
58
+
59
+ # 检查目标路径是否已经存在
60
+ if os.path.exists(destination_path):
61
+ print(f"目标目录 {destination_path} 已经存在,删除该目录并重新克隆仓库...")
62
+ try:
63
+ # 删除已存在的目录
64
+ subprocess.run(f"sudo rm -rf {destination_path}", shell=True, check=True)
65
+ except subprocess.CalledProcessError as e:
66
+ return f"删除目录时出错: {e}"
67
 
68
+ # 执行 git clone 命令
69
+ clone_command = f"git clone {repo_url} {destination_path}"
70
  try:
71
  # 使用 subprocess 调用 git clone
72
  subprocess.run(clone_command, shell=True, check=True)