Spaces:
Running
Running
admin
commited on
Commit
•
0e56268
1
Parent(s):
08d296b
fix pop monitors
Browse files
app.py
CHANGED
@@ -104,16 +104,12 @@ def get_spaces(username: str):
|
|
104 |
response.raise_for_status()
|
105 |
# 解析JSON响应
|
106 |
spaces: list = response.json()["spaces"]
|
107 |
-
|
108 |
for space in spaces:
|
109 |
if space["author"] == username:
|
110 |
-
|
111 |
-
if "keep-spaces-active" in url:
|
112 |
-
monitors.append(url)
|
113 |
-
else:
|
114 |
-
studios.append(url)
|
115 |
|
116 |
-
return
|
117 |
|
118 |
except requests.exceptions.Timeout as errt:
|
119 |
print(f"请求超时: {errt}, retrying...")
|
@@ -192,6 +188,14 @@ def activate(hf_users: str, ms_users: str):
|
|
192 |
spaces += get_spaces(username)
|
193 |
time.sleep(DELAY)
|
194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
for user in tqdm(ms_usernames, desc="Collecting studios..."):
|
196 |
username = user.strip()
|
197 |
if username:
|
|
|
104 |
response.raise_for_status()
|
105 |
# 解析JSON响应
|
106 |
spaces: list = response.json()["spaces"]
|
107 |
+
studios = []
|
108 |
for space in spaces:
|
109 |
if space["author"] == username:
|
110 |
+
studios.append(f"https://{space['id'].replace('/', '-')}.hf.space")
|
|
|
|
|
|
|
|
|
111 |
|
112 |
+
return studios
|
113 |
|
114 |
except requests.exceptions.Timeout as errt:
|
115 |
print(f"请求超时: {errt}, retrying...")
|
|
|
188 |
spaces += get_spaces(username)
|
189 |
time.sleep(DELAY)
|
190 |
|
191 |
+
monitors, studios = [], []
|
192 |
+
for space in spaces:
|
193 |
+
if "keep-spaces-active" in space:
|
194 |
+
monitors.append(space)
|
195 |
+
else:
|
196 |
+
studios.append(space)
|
197 |
+
space = monitors + studios
|
198 |
+
|
199 |
for user in tqdm(ms_usernames, desc="Collecting studios..."):
|
200 |
username = user.strip()
|
201 |
if username:
|