Spaces:
Running
on
T4
Running
on
T4
File size: 1,244 Bytes
401e785 6f813ab 401e785 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import os
import requests
import subprocess
import time
from tqdm import tqdm
def download(filename, url):
try:
response = requests.get(url, stream=True)
total_size = int(response.headers.get("content-length", 0))
chunk_size = 1024
with open(filename, "wb") as file, tqdm(
desc=f"Downloading {filename} from '{url}'...",
total=total_size,
unit="B",
unit_scale=True,
unit_divisor=1024,
) as bar:
for data in response.iter_content(chunk_size=chunk_size):
size = file.write(data)
bar.update(size)
except Exception as e:
print(f"Error: {e}, retrying...")
time.sleep(10)
download(filename, url)
apkname = "MuseScore.AppImage"
extra_dir = "squashfs-root"
if not os.path.exists(apkname):
download(
filename=apkname,
url="https://www.modelscope.cn/studio/Genius-Society/piano_trans/resolve/master/MuseScore.AppImage",
)
if not os.path.exists(extra_dir):
subprocess.run(["chmod", "+x", f"./{apkname}"])
subprocess.run([f"./{apkname}", "--appimage-extract"])
MSCORE = f"./{extra_dir}/AppRun"
os.environ["QT_QPA_PLATFORM"] = "offscreen" |