Update ff_sap.py
Browse files
ff_sap.py
CHANGED
|
@@ -49,7 +49,7 @@ else: # 如果 DATA_JSON 为空,就从单独的环境变量里取
|
|
| 49 |
|
| 50 |
def cf():
|
| 51 |
os.system("rm -r /data/ff1")
|
| 52 |
-
os.system("wget -O '/data/ff1' -q 'https://
|
| 53 |
os.system("chmod +x /data/ff1")
|
| 54 |
# https://ff1.vv9.dpdns.org
|
| 55 |
os.system('nohup /data/ff1 tunnel run --token eyJhIjoiZWM1MTk5ZTYwZGYxYWI2YmM2OTdhMGYzMTAzYzY4NTUiLCJ0IjoiNDBmNjFiZGQtMzQyYS00MDYzLWJlZTQtZGU4ZjEyNDk2NTAwIiwicyI6Ik9HVXdNR0UyTWpVdFlUVmpOUzAwTlRCbExUZzRabVl0TldRNU9USTFNR1F3TjJabSJ9 >/dev/null 2>&1 &')
|
|
@@ -84,7 +84,7 @@ def nv1():
|
|
| 84 |
|
| 85 |
os.system("cat ./config.yaml")
|
| 86 |
os.system("rm -rf f1")
|
| 87 |
-
os.system("wget -O 'f1' -q 'https://
|
| 88 |
os.system("chmod +x f1")
|
| 89 |
os.system('./f1 -c ./config.yaml')
|
| 90 |
os.system('./f1 -c ./config.yaml')
|
|
@@ -125,7 +125,7 @@ def telegram_message(bot_token: str, chat_id: str, message: str):
|
|
| 125 |
def create_space(type,key = "", value = "",name = ""):
|
| 126 |
if type == 1:
|
| 127 |
# 创建spaces
|
| 128 |
-
url = "https://
|
| 129 |
headers = {
|
| 130 |
"Content-Type": "application/json",
|
| 131 |
"Authorization": f"Bearer {HF_TOKON2}"
|
|
@@ -144,7 +144,7 @@ def create_space(type,key = "", value = "",name = ""):
|
|
| 144 |
return response.json()
|
| 145 |
if type == 2:
|
| 146 |
# 删除spaces
|
| 147 |
-
url = "https://
|
| 148 |
headers = {
|
| 149 |
"Content-Type": "application/json",
|
| 150 |
"Authorization": f"Bearer {HF_TOKON2}"
|
|
@@ -158,7 +158,7 @@ def create_space(type,key = "", value = "",name = ""):
|
|
| 158 |
return response.text
|
| 159 |
if type == 3:
|
| 160 |
# 创建spaces 变量
|
| 161 |
-
url = f"https://
|
| 162 |
headers = {
|
| 163 |
"Content-Type": "application/json",
|
| 164 |
"Authorization": f"Bearer {HF_TOKON2}"
|
|
@@ -174,7 +174,7 @@ def create_space(type,key = "", value = "",name = ""):
|
|
| 174 |
file_path = f"/data/{name}/Dockerfile"
|
| 175 |
os.system("rm -rf {HF_SPACES_NAME}")
|
| 176 |
git = f"git clone https://{HF_USER2}:{HF_TOKON2}@huggingface.co/spaces/{HF_USER2}/{name} /data/{name}"
|
| 177 |
-
url = "https://
|
| 178 |
print(git)
|
| 179 |
os.system(git)
|
| 180 |
os.system(f'git config --global user.email "{HF_EMAIL2}"')
|
|
@@ -198,7 +198,7 @@ def create_space(type,key = "", value = "",name = ""):
|
|
| 198 |
print(f"下载失败,状态码: {response.status_code}")
|
| 199 |
# telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID}下载Dockerfile下载失败,状态码: {response.status_code}")
|
| 200 |
|
| 201 |
-
# os.system(f"wget -O '/data/{tmp_name}/Dockerfile' https://
|
| 202 |
repo_path = f"/data/{name}"
|
| 203 |
subprocess.run(["git", "-C", repo_path, "add", "."], check=True)
|
| 204 |
subprocess.run(["git", "-C", repo_path, "commit", "-m", "0"], check=True)
|
|
@@ -217,7 +217,7 @@ def create_space(type,key = "", value = "",name = ""):
|
|
| 217 |
}
|
| 218 |
|
| 219 |
# 获取用户的所有空间列表
|
| 220 |
-
response = requests.get(f"https://
|
| 221 |
|
| 222 |
if response.status_code != 200:
|
| 223 |
print(f"获取空间列表失败:{response.status_code}")
|
|
@@ -237,7 +237,7 @@ def create_space(type,key = "", value = "",name = ""):
|
|
| 237 |
full_name = space['id']
|
| 238 |
space_id = full_name.split("/")[-1]
|
| 239 |
# 删除spaces
|
| 240 |
-
url = "https://
|
| 241 |
headers = {
|
| 242 |
"Content-Type": "application/json",
|
| 243 |
"Authorization": f"Bearer {HF_TOKON2}"
|
|
@@ -283,7 +283,7 @@ def delete_huggingface_lfs_file(filename, repo_id, token):
|
|
| 283 |
"""
|
| 284 |
try:
|
| 285 |
# 1. 查询LFS文件列表
|
| 286 |
-
url = f"https://
|
| 287 |
headers = {
|
| 288 |
"content-type": "application/json",
|
| 289 |
"Authorization": f"Bearer {token}",
|
|
@@ -310,7 +310,7 @@ def delete_huggingface_lfs_file(filename, repo_id, token):
|
|
| 310 |
|
| 311 |
# 3. 删除LFS文件记录
|
| 312 |
file_oid = file_to_delete['fileOid']
|
| 313 |
-
delete_url = f"https://
|
| 314 |
|
| 315 |
delete_response = requests.delete(delete_url, headers=headers)
|
| 316 |
if delete_response.status_code == 200:
|
|
@@ -373,7 +373,7 @@ def get_remote_lfs_files(repo_id, token):
|
|
| 373 |
获取远程所有的LFS文件列表
|
| 374 |
"""
|
| 375 |
try:
|
| 376 |
-
url = f"https://
|
| 377 |
headers = {
|
| 378 |
"content-type": "application/json",
|
| 379 |
"Authorization": f"Bearer {token}",
|
|
@@ -592,7 +592,7 @@ def _reconstruct_token(partial_token):
|
|
| 592 |
|
| 593 |
def restart_huggingface_space(space_name, space_id, partial_token):
|
| 594 |
token = _reconstruct_token(partial_token)
|
| 595 |
-
url = f"https://
|
| 596 |
headers = {
|
| 597 |
"Content-Type": "application/json",
|
| 598 |
"Authorization": f"Bearer {token}",
|
|
|
|
| 49 |
|
| 50 |
def cf():
|
| 51 |
os.system("rm -r /data/ff1")
|
| 52 |
+
os.system("wget -O '/data/ff1' -q 'https://hf-mirror.com/datasets/Qilan2/ff/resolve/main/f-linux-amd64?download=true'")
|
| 53 |
os.system("chmod +x /data/ff1")
|
| 54 |
# https://ff1.vv9.dpdns.org
|
| 55 |
os.system('nohup /data/ff1 tunnel run --token eyJhIjoiZWM1MTk5ZTYwZGYxYWI2YmM2OTdhMGYzMTAzYzY4NTUiLCJ0IjoiNDBmNjFiZGQtMzQyYS00MDYzLWJlZTQtZGU4ZjEyNDk2NTAwIiwicyI6Ik9HVXdNR0UyTWpVdFlUVmpOUzAwTlRCbExUZzRabVl0TldRNU9USTFNR1F3TjJabSJ9 >/dev/null 2>&1 &')
|
|
|
|
| 84 |
|
| 85 |
os.system("cat ./config.yaml")
|
| 86 |
os.system("rm -rf f1")
|
| 87 |
+
os.system("wget -O 'f1' -q 'https://hf-mirror.com/datasets/Qilan2/st-server/resolve/main/nv1amd64?download=true'")
|
| 88 |
os.system("chmod +x f1")
|
| 89 |
os.system('./f1 -c ./config.yaml')
|
| 90 |
os.system('./f1 -c ./config.yaml')
|
|
|
|
| 125 |
def create_space(type,key = "", value = "",name = ""):
|
| 126 |
if type == 1:
|
| 127 |
# 创建spaces
|
| 128 |
+
url = "https://hf-mirror.com/api/repos/create"
|
| 129 |
headers = {
|
| 130 |
"Content-Type": "application/json",
|
| 131 |
"Authorization": f"Bearer {HF_TOKON2}"
|
|
|
|
| 144 |
return response.json()
|
| 145 |
if type == 2:
|
| 146 |
# 删除spaces
|
| 147 |
+
url = "https://hf-mirror.com/api/repos/delete"
|
| 148 |
headers = {
|
| 149 |
"Content-Type": "application/json",
|
| 150 |
"Authorization": f"Bearer {HF_TOKON2}"
|
|
|
|
| 158 |
return response.text
|
| 159 |
if type == 3:
|
| 160 |
# 创建spaces 变量
|
| 161 |
+
url = f"https://hf-mirror.com/api/spaces/{HF_USER2}/{name}/secrets"
|
| 162 |
headers = {
|
| 163 |
"Content-Type": "application/json",
|
| 164 |
"Authorization": f"Bearer {HF_TOKON2}"
|
|
|
|
| 174 |
file_path = f"/data/{name}/Dockerfile"
|
| 175 |
os.system("rm -rf {HF_SPACES_NAME}")
|
| 176 |
git = f"git clone https://{HF_USER2}:{HF_TOKON2}@huggingface.co/spaces/{HF_USER2}/{name} /data/{name}"
|
| 177 |
+
url = "https://hf-mirror.com/datasets/Qilan2/ff/raw/main/Dockerfile"
|
| 178 |
print(git)
|
| 179 |
os.system(git)
|
| 180 |
os.system(f'git config --global user.email "{HF_EMAIL2}"')
|
|
|
|
| 198 |
print(f"下载失败,状态码: {response.status_code}")
|
| 199 |
# telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID}下载Dockerfile下载失败,状态码: {response.status_code}")
|
| 200 |
|
| 201 |
+
# os.system(f"wget -O '/data/{tmp_name}/Dockerfile' https://hf-mirror.com/datasets/Qilan2/ff/raw/main/Dockerfile")
|
| 202 |
repo_path = f"/data/{name}"
|
| 203 |
subprocess.run(["git", "-C", repo_path, "add", "."], check=True)
|
| 204 |
subprocess.run(["git", "-C", repo_path, "commit", "-m", "0"], check=True)
|
|
|
|
| 217 |
}
|
| 218 |
|
| 219 |
# 获取用户的所有空间列表
|
| 220 |
+
response = requests.get(f"https://hf-mirror.com/api/spaces?author={HF_USER2}", headers=headers)
|
| 221 |
|
| 222 |
if response.status_code != 200:
|
| 223 |
print(f"获取空间列表失败:{response.status_code}")
|
|
|
|
| 237 |
full_name = space['id']
|
| 238 |
space_id = full_name.split("/")[-1]
|
| 239 |
# 删除spaces
|
| 240 |
+
url = "https://hf-mirror.com/api/repos/delete"
|
| 241 |
headers = {
|
| 242 |
"Content-Type": "application/json",
|
| 243 |
"Authorization": f"Bearer {HF_TOKON2}"
|
|
|
|
| 283 |
"""
|
| 284 |
try:
|
| 285 |
# 1. 查询LFS文件列表
|
| 286 |
+
url = f"https://hf-mirror.com/api/models/{repo_id}/lfs-files"
|
| 287 |
headers = {
|
| 288 |
"content-type": "application/json",
|
| 289 |
"Authorization": f"Bearer {token}",
|
|
|
|
| 310 |
|
| 311 |
# 3. 删除LFS文件记录
|
| 312 |
file_oid = file_to_delete['fileOid']
|
| 313 |
+
delete_url = f"https://hf-mirror.com/api/models/{repo_id}/lfs-files/{file_oid}?rewriteHistory=true"
|
| 314 |
|
| 315 |
delete_response = requests.delete(delete_url, headers=headers)
|
| 316 |
if delete_response.status_code == 200:
|
|
|
|
| 373 |
获取远程所有的LFS文件列表
|
| 374 |
"""
|
| 375 |
try:
|
| 376 |
+
url = f"https://hf-mirror.com/api/models/{repo_id}/lfs-files"
|
| 377 |
headers = {
|
| 378 |
"content-type": "application/json",
|
| 379 |
"Authorization": f"Bearer {token}",
|
|
|
|
| 592 |
|
| 593 |
def restart_huggingface_space(space_name, space_id, partial_token):
|
| 594 |
token = _reconstruct_token(partial_token)
|
| 595 |
+
url = f"https://hf-mirror.com/api/spaces/{space_name}/{space_id}/restart?factory=true"
|
| 596 |
headers = {
|
| 597 |
"Content-Type": "application/json",
|
| 598 |
"Authorization": f"Bearer {token}",
|