Spaces:
Running
Running
Update dl.py
Browse files
dl.py
CHANGED
@@ -73,9 +73,7 @@ def show_all(author,token):
|
|
73 |
#print (f_ist)
|
74 |
if not os.path.exists(space_ea):
|
75 |
os.makedirs(space_ea)
|
76 |
-
|
77 |
-
shutil.make_archive("temp", 'zip', file)
|
78 |
-
return "temp.zip"
|
79 |
for d_app in f_ist:
|
80 |
|
81 |
r = requests.get(f'https://huggingface.co/spaces/{author}/{space_ea}/raw/main/{d_app}')
|
@@ -107,7 +105,33 @@ def show_all(author,token):
|
|
107 |
pass
|
108 |
file_list.append(f'{author}.zip')
|
109 |
return file_list
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
|
113 |
def checkp(p):
|
@@ -141,7 +165,7 @@ with gr.Blocks() as build:
|
|
141 |
m_t=gr.Textbox(max_lines=100)
|
142 |
uu=gr.Textbox(visible=False)
|
143 |
|
144 |
-
show_all_btn.click(
|
145 |
|
146 |
s_btn.click(show_s,[r_name,token],s_name)
|
147 |
s_name.change(show_f,[r_name,s_name,token],[d_app,files])
|
|
|
73 |
#print (f_ist)
|
74 |
if not os.path.exists(space_ea):
|
75 |
os.makedirs(space_ea)
|
76 |
+
|
|
|
|
|
77 |
for d_app in f_ist:
|
78 |
|
79 |
r = requests.get(f'https://huggingface.co/spaces/{author}/{space_ea}/raw/main/{d_app}')
|
|
|
105 |
pass
|
106 |
file_list.append(f'{author}.zip')
|
107 |
return file_list
|
108 |
+
|
109 |
+
def show_all_z(author,token):
|
110 |
+
spaces=[]
|
111 |
+
api = HfApi(token=token)
|
112 |
+
#author=name
|
113 |
+
s_ist = (api.list_spaces(author=author))
|
114 |
+
file_list = []
|
115 |
+
file_list_ea=[]
|
116 |
+
for i,space in enumerate(s_ist):
|
117 |
+
space_ea = space.id.split("/",1)[1]
|
118 |
+
spaces.append(space_ea)
|
119 |
+
#print (space_ea)
|
120 |
+
f_ist = (api.list_repo_files(repo_id=f'{author}/{space_ea}', repo_type="space"))
|
121 |
+
#print (f_ist)
|
122 |
+
if not os.path.exists(space_ea):
|
123 |
+
os.makedirs(space_ea)
|
124 |
+
file= snapshot_download(repo_id=f'{author}/{space_ea}', repo_type="space")
|
125 |
+
shutil.make_archive(f"{space_ea}", 'zip', file)
|
126 |
+
file_list.append(f'{space_ea}.zip')
|
127 |
+
with ZipFile(f"{author}.zip", "w") as zipObj:
|
128 |
+
for idx, file in enumerate(file_list):
|
129 |
+
try:
|
130 |
+
zipObj.write(f'{file}')
|
131 |
+
except Exception:
|
132 |
+
pass
|
133 |
+
file_list.append(f'{author}.zip')
|
134 |
+
return file_list
|
135 |
|
136 |
|
137 |
def checkp(p):
|
|
|
165 |
m_t=gr.Textbox(max_lines=100)
|
166 |
uu=gr.Textbox(visible=False)
|
167 |
|
168 |
+
show_all_btn.click(show_all_z),[r_name,token],files)
|
169 |
|
170 |
s_btn.click(show_s,[r_name,token],s_name)
|
171 |
s_name.change(show_f,[r_name,s_name,token],[d_app,files])
|