Qilan2 commited on
Commit
64a5705
·
verified ·
1 Parent(s): e23752a

Update ff1.py

Browse files
Files changed (1) hide show
  1. ff1.py +18 -3
ff1.py CHANGED
@@ -168,15 +168,30 @@ def create_space(type,key = "", value = ""):
168
  response = requests.post(url, headers=headers, json=payload)
169
  return response.text
170
  if type == 4:
 
171
  os.system("rm -rf {HF_SPACES_NAME}")
172
  git = f"git clone https://{HF_USER2}:{HF_TOKON2}@huggingface.co/spaces/{HF_USER2}/{tmp_name}"
 
173
  print(git)
174
  os.system(git)
175
  os.system(f'git config --global user.email "{HF_EMAIL2}"')
176
  os.system(f'git config --global user.name "{HF_USER2}"')
177
  os.chdir(f'/data/{tmp_name}')
178
- os.system('rm -rf Dockerfile')
179
- os.system(f"wget -O '/data/{tmp_name}/Dockerfile' https://huggingface.co/datasets/Qilan2/ff/raw/main/Dockerfile")
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  os.system('git add .')
181
  os.system('git commit -m "0"')
182
  os.system('git push origin main')
@@ -581,7 +596,7 @@ if os.path.exists('/data/ff/.mozilla/firefox/profiles.ini') and os.path.isfile('
581
  print("检测到Firefox配置,启动定期重启循环...")
582
  response = create_space(2)
583
  print(response)
584
- time.sleep(21600)#21600 = 6小时
585
  github(2)
586
  response = create_space(1)
587
  print(response)
 
168
  response = requests.post(url, headers=headers, json=payload)
169
  return response.text
170
  if type == 4:
171
+ file_path = f"/data/{tmp_name}/Dockerfile"
172
  os.system("rm -rf {HF_SPACES_NAME}")
173
  git = f"git clone https://{HF_USER2}:{HF_TOKON2}@huggingface.co/spaces/{HF_USER2}/{tmp_name}"
174
+ url = "https://huggingface.co/datasets/Qilan2/ff/raw/main/Dockerfile"
175
  print(git)
176
  os.system(git)
177
  os.system(f'git config --global user.email "{HF_EMAIL2}"')
178
  os.system(f'git config --global user.name "{HF_USER2}"')
179
  os.chdir(f'/data/{tmp_name}')
180
+ time.sleep(3)
181
+ # 如果文件已存在,先删除
182
+ if os.path.exists(file_path):
183
+ print(f"文件已存在,删除: {file_path}")
184
+ os.remove(file_path)
185
+ print(f"正在下载 {url} 到 {file_path}")
186
+ response = requests.get(url)
187
+ if response.status_code == 200:
188
+ os.makedirs(os.path.dirname(file_path), exist_ok=True)
189
+ with open(file_path, "wb") as f:
190
+ f.write(response.content)
191
+ print("下载完成 ✅")
192
+ else:
193
+ print(f"下载失败,状态码: {response.status_code}")
194
+ # os.system(f"wget -O '/data/{tmp_name}/Dockerfile' https://huggingface.co/datasets/Qilan2/ff/raw/main/Dockerfile")
195
  os.system('git add .')
196
  os.system('git commit -m "0"')
197
  os.system('git push origin main')
 
596
  print("检测到Firefox配置,启动定期重启循环...")
597
  response = create_space(2)
598
  print(response)
599
+ time.sleep(60)#21600 = 6小时
600
  github(2)
601
  response = create_space(1)
602
  print(response)