Spaces:
Sleeping
Sleeping
Update server.py
Browse files
server.py
CHANGED
@@ -86,11 +86,16 @@ def extract_zip_if_needed(zip_path, dest_dir):
|
|
86 |
print(f"β
Extracted to: {dest_dir}")
|
87 |
|
88 |
def print_directory_tree(path):
|
|
|
89 |
for root, dirs, files in os.walk(path):
|
90 |
indent = ' ' * (root.count(os.sep) - path.count(os.sep))
|
91 |
-
|
|
|
|
|
92 |
for f in files:
|
93 |
-
|
|
|
|
|
94 |
|
95 |
|
96 |
def copy_zip_extract_and_report():
|
@@ -126,10 +131,11 @@ def copy_zip_extract_and_report():
|
|
126 |
extract_zip_if_needed(dst_zip, extract_path)
|
127 |
|
128 |
print("\nπ¦ Local hf_cache structure:")
|
129 |
-
print_directory_tree("./hf_cache")
|
130 |
|
131 |
print("\nπΎ Persistent /data/hf_cache structure:")
|
132 |
-
print_directory_tree("/data/hf_cache")
|
|
|
133 |
|
134 |
|
135 |
|
@@ -138,11 +144,9 @@ def copy_and_extract():
|
|
138 |
import io
|
139 |
from contextlib import redirect_stdout
|
140 |
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
output = f.getvalue()
|
145 |
-
return {"message": "done", "log": output}
|
146 |
|
147 |
|
148 |
|
|
|
86 |
print(f"β
Extracted to: {dest_dir}")
|
87 |
|
88 |
def print_directory_tree(path):
|
89 |
+
printstr = ''
|
90 |
for root, dirs, files in os.walk(path):
|
91 |
indent = ' ' * (root.count(os.sep) - path.count(os.sep))
|
92 |
+
printstr += indent
|
93 |
+
printstr += os.path.basename(root)
|
94 |
+
printstr += '\n'
|
95 |
for f in files:
|
96 |
+
printstr += indent
|
97 |
+
printstr += f
|
98 |
+
return printstr
|
99 |
|
100 |
|
101 |
def copy_zip_extract_and_report():
|
|
|
131 |
extract_zip_if_needed(dst_zip, extract_path)
|
132 |
|
133 |
print("\nπ¦ Local hf_cache structure:")
|
134 |
+
printstr1 = print_directory_tree("./hf_cache")
|
135 |
|
136 |
print("\nπΎ Persistent /data/hf_cache structure:")
|
137 |
+
printstr2 = print_directory_tree("/data/hf_cache")
|
138 |
+
return printstr1 + '\n\n' + printstr2
|
139 |
|
140 |
|
141 |
|
|
|
144 |
import io
|
145 |
from contextlib import redirect_stdout
|
146 |
|
147 |
+
printstr = copy_zip_extract_and_report()
|
148 |
+
|
149 |
+
return {"message": "done", "log": printstr}
|
|
|
|
|
150 |
|
151 |
|
152 |
|