Spaces:
Running
Running
admin
commited on
Commit
•
ad37aa7
1
Parent(s):
c8fa0ba
upd app
Browse files
app.py
CHANGED
@@ -101,7 +101,11 @@ def activate_space(url: str):
|
|
101 |
success = "success"
|
102 |
try:
|
103 |
# 发送GET请求获取页面内容
|
104 |
-
response =
|
|
|
|
|
|
|
|
|
105 |
response.raise_for_status() # 确保请求成功
|
106 |
web_page_content = response.text
|
107 |
|
@@ -148,7 +152,7 @@ def activate_space(url: str):
|
|
148 |
return activate_space(url)
|
149 |
|
150 |
except requests.RequestException as e:
|
151 |
-
success = f"{e}"
|
152 |
|
153 |
except Exception as e:
|
154 |
success = f"{e}"
|
@@ -179,8 +183,8 @@ def activate(hf_users: str, ms_users: str):
|
|
179 |
time.sleep(DELAY)
|
180 |
|
181 |
output = []
|
182 |
-
for space in tqdm(spaces, desc="Activating spaces..."):
|
183 |
-
output.append({"space":
|
184 |
time.sleep(DELAY)
|
185 |
|
186 |
print("Activation complete!")
|
@@ -208,7 +212,8 @@ def monitor(hf_users: str, ms_users: str, period=3):
|
|
208 |
def list_tasks():
|
209 |
jobs = schedule.get_jobs()
|
210 |
if jobs:
|
211 |
-
|
|
|
212 |
|
213 |
return "None"
|
214 |
|
|
|
101 |
success = "success"
|
102 |
try:
|
103 |
# 发送GET请求获取页面内容
|
104 |
+
response = (
|
105 |
+
requests.get(url, timeout=TIMEOUT)
|
106 |
+
if "https://huggingface.co/spaces" in url
|
107 |
+
else requests.put(url)
|
108 |
+
)
|
109 |
response.raise_for_status() # 确保请求成功
|
110 |
web_page_content = response.text
|
111 |
|
|
|
152 |
return activate_space(url)
|
153 |
|
154 |
except requests.RequestException as e:
|
155 |
+
success = "success" if "500 Server Error:" in f"{e}" else f"{e}"
|
156 |
|
157 |
except Exception as e:
|
158 |
success = f"{e}"
|
|
|
183 |
time.sleep(DELAY)
|
184 |
|
185 |
output = []
|
186 |
+
for i, space in enumerate(tqdm(spaces, desc="Activating spaces...")):
|
187 |
+
output.append({"space": f"{i + 1}", "status": activate_space(space)})
|
188 |
time.sleep(DELAY)
|
189 |
|
190 |
print("Activation complete!")
|
|
|
212 |
def list_tasks():
|
213 |
jobs = schedule.get_jobs()
|
214 |
if jobs:
|
215 |
+
details = f"{jobs}".replace("[", "").replace("]", "")
|
216 |
+
return details.split("functools.")[0] + "(" + details.split(") (")[-1]
|
217 |
|
218 |
return "None"
|
219 |
|