Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,27 +3,38 @@ import zipfile
|
|
| 3 |
import sys
|
| 4 |
|
| 5 |
ZIP_NAME = "musicnbrain.zip"
|
| 6 |
-
MARKER
|
| 7 |
|
| 8 |
def unzip_once():
|
|
|
|
|
|
|
| 9 |
if not os.path.exists(ZIP_NAME):
|
| 10 |
-
print(f"
|
| 11 |
return
|
|
|
|
| 12 |
if os.path.exists(MARKER):
|
| 13 |
-
print("
|
| 14 |
return
|
| 15 |
|
| 16 |
-
with zipfile.ZipFile(ZIP_NAME, "r") as zf:
|
| 17 |
-
zf.extractall(".")
|
| 18 |
-
# optional: delete the zip to save space
|
| 19 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
os.remove(ZIP_NAME)
|
| 21 |
-
|
| 22 |
-
print("⚠️ Couldn’t delete zip:", e)
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
if __name__ == "__main__":
|
| 29 |
unzip_once()
|
|
|
|
| 3 |
import sys
|
| 4 |
|
| 5 |
ZIP_NAME = "musicnbrain.zip"
|
| 6 |
+
MARKER = ".unzipped_ok"
|
| 7 |
|
| 8 |
def unzip_once():
|
| 9 |
+
print("Starting unzip script...")
|
| 10 |
+
|
| 11 |
if not os.path.exists(ZIP_NAME):
|
| 12 |
+
print(f"'{ZIP_NAME}' not found — nothing to unzip.")
|
| 13 |
return
|
| 14 |
+
|
| 15 |
if os.path.exists(MARKER):
|
| 16 |
+
print("Already unzipped. Skipping.")
|
| 17 |
return
|
| 18 |
|
|
|
|
|
|
|
|
|
|
| 19 |
try:
|
| 20 |
+
with zipfile.ZipFile(ZIP_NAME, "r") as zf:
|
| 21 |
+
print(f"Extracting {ZIP_NAME}...")
|
| 22 |
+
zf.extractall(".")
|
| 23 |
+
print("Extraction complete.")
|
| 24 |
+
|
| 25 |
os.remove(ZIP_NAME)
|
| 26 |
+
print("Deleted zip file.")
|
|
|
|
| 27 |
|
| 28 |
+
open(MARKER, "w").close()
|
| 29 |
+
print("Created marker file.")
|
| 30 |
+
|
| 31 |
+
print("\nExtracted files:")
|
| 32 |
+
for root, dirs, files in os.walk("."):
|
| 33 |
+
for file in files:
|
| 34 |
+
print(os.path.join(root, file))
|
| 35 |
+
|
| 36 |
+
except Exception as e:
|
| 37 |
+
print("Unzip failed:", e)
|
| 38 |
|
| 39 |
if __name__ == "__main__":
|
| 40 |
unzip_once()
|