tentando resolver problema do download do zip no mmpCreator
This commit is contained in:
1 parent
1847d1eba8
commit
331bb27ed1
5 files changed
+370432
-358055
No files matched your search
@@ -84,11 +84,17 @@ def allowed_sample(filename):
|
||||
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_SAMPLE_EXTENSIONS
|
||||
|
||||
def run_jekyll_build():
|
||||
RUBY_BIN_PATH = "/usr/bin/ruby3.2"
|
||||
BUNDLE_PATH = "/nethome/jotachina/projetos/mmpSearch/vendor/bundle/ruby/3.2.0/bin/bundle"
|
||||
# Prepara o ambiente para o subprocesso
|
||||
env_vars = os.environ.copy()
|
||||
# Adiciona o caminho do Ruby ao PATH do usuário www-data temporariamente
|
||||
env_vars["PATH"] = f"{RUBY_BIN_PATH}:{env_vars.get('PATH', '')}"
|
||||
print("Iniciando build do Jekyll...")
|
||||
command = [BUNDLE_PATH, "exec", "jekyll", "build", "--destination", "/var/www/html/trens/mmpSearch/"]
|
||||
try:
|
||||
subprocess.run(command, check=True, cwd=BASE_DATA, capture_output=True, text=True)
|
||||
# Passamos env=env_vars para que ele ache o ruby3.2
|
||||
subprocess.run(command, check=True, cwd=BASE_DATA, capture_output=True, text=True, env=env_vars)
|
||||
print("Jekyll Build Sucesso!")
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"ERRO no Jekyll Build: {e.stderr}")
|
||||
@@ -105,6 +111,7 @@ def load_manifest_keys():
|
||||
return []
|
||||
|
||||
def convert_mmpz_to_mmp(mmpz_path, mmp_target_path):
|
||||
LMMS_PATH = "/usr/bin/lmms"
|
||||
"""Tenta descompactar .mmpz usando Python ou LMMS CLI."""
|
||||
print(f"Tentando converter: {mmpz_path} -> {mmp_target_path}")
|
||||
|
||||
@@ -116,56 +123,32 @@ def convert_mmpz_to_mmp(mmpz_path, mmp_target_path):
|
||||
pass
|
||||
|
||||
if content:
|
||||
# 1.1 Tenta ZIP
|
||||
if zipfile.is_zipfile(mmpz_path):
|
||||
try:
|
||||
with zipfile.ZipFile(mmpz_path, 'r') as z:
|
||||
with open(mmp_target_path, 'wb') as f_out:
|
||||
f_out.write(z.read(z.namelist()[0]))
|
||||
print("Sucesso: Descompactado via ZIP.")
|
||||
return True
|
||||
except: pass
|
||||
# --- Fallback para LMMS CLI ---
|
||||
# VERIFICAÇÃO DE SEGURANÇA: O binário existe?
|
||||
if not os.path.exists(LMMS_PATH):
|
||||
print(f"ERRO CRÍTICO: Executável do LMMS não encontrado em {LMMS_PATH}")
|
||||
return False
|
||||
print("Métodos Python falharam. Tentando fallback via LMMS CLI...")
|
||||
cmd = [LMMS_PATH, "--dump", mmpz_path]
|
||||
env_vars = os.environ.copy()
|
||||
env_vars["QT_QPA_PLATFORM"] = "offscreen"
|
||||
|
||||
# 1.2 Tenta GZIP
|
||||
try:
|
||||
decompressed = gzip.decompress(content)
|
||||
with open(mmp_target_path, "wb") as f_out:
|
||||
f_out.write(decompressed)
|
||||
print("Sucesso: Descompactado via GZIP.")
|
||||
return True
|
||||
except: pass
|
||||
|
||||
# 1.3 Tenta ZLIB
|
||||
try:
|
||||
decompressed = zlib.decompress(content)
|
||||
with open(mmp_target_path, "wb") as f_out:
|
||||
f_out.write(decompressed)
|
||||
print("Sucesso: Descompactado via ZLIB.")
|
||||
return True
|
||||
except: pass
|
||||
|
||||
# --- Fallback para LMMS CLI ---
|
||||
print("Métodos Python falharam. Tentando fallback via LMMS CLI...")
|
||||
cmd = ["lmms", "--dump", mmpz_path]
|
||||
env_vars = os.environ.copy()
|
||||
env_vars["QT_QPA_PLATFORM"] = "offscreen"
|
||||
|
||||
try:
|
||||
with open(mmp_target_path, "w") as f_out:
|
||||
subprocess.run(cmd, stdout=f_out, stderr=subprocess.PIPE, check=True, env=env_vars)
|
||||
|
||||
if os.path.exists(mmp_target_path) and os.path.getsize(mmp_target_path) > 0:
|
||||
print("Sucesso: Descompactado via LMMS CLI (--dump).")
|
||||
return True
|
||||
else:
|
||||
print("Erro: LMMS CLI rodou, mas arquivo de saída está vazio.")
|
||||
with open(mmp_target_path, "w") as f_out:
|
||||
subprocess.run(cmd, stdout=f_out, stderr=subprocess.PIPE, check=True, env=env_vars)
|
||||
|
||||
if os.path.exists(mmp_target_path) and os.path.getsize(mmp_target_path) > 0:
|
||||
print("Sucesso: Descompactado via LMMS CLI (--dump).")
|
||||
return True
|
||||
else:
|
||||
print("Erro: LMMS CLI rodou, mas arquivo de saída está vazio.")
|
||||
return False
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Falha crítica no LMMS CLI: {e.stderr.decode('utf-8') if e.stderr else str(e)}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"Erro inesperado ao chamar LMMS: {e}")
|
||||
return False
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Falha crítica no LMMS CLI: {e.stderr.decode('utf-8') if e.stderr else str(e)}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"Erro inesperado ao chamar LMMS: {e}")
|
||||
return False
|
||||
|
||||
def analyze_mmp_dependencies(mmp_filename):
|
||||
"""Analisa um arquivo .mmp XML puro."""
|
||||
|
||||
Reference in new issue
Block a user