Skip to content

Commit

Permalink
Update installman.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Danucosukosuko authored Oct 12, 2024
1 parent caac201 commit 234f12b
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions installman.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
import requests
import zipfile
import subprocess
import base64
from cryptography.fernet import Fernet, InvalidToken
import hashlib
import sys
import urllib3
from tqdm import tqdm
from termcolor import colored
import shutil

# URL del archivo de clave
KEY_URL = "https://github.com/danucosukosuko/installmanpkgs/raw/main/key.iky"
Expand All @@ -29,7 +25,7 @@ def get_secret_key():
response = requests.get(KEY_URL)
response.raise_for_status() # Verifica si la solicitud fue exitosa
return response.content.strip()
except requests.exceptions.RequestException as e:
except requests.exceptions.RequestException:
print(colored("No se pueden encontrar los paquetes. Revise su conexión a internet e inténtelo de nuevo más tarde.", 'red'))
sys.exit(1)

Expand Down Expand Up @@ -63,7 +59,7 @@ def get_available_packages():
response.raise_for_status()
packages = [item['name'] for item in response.json() if item['name'].endswith('.zip')]
return packages
except requests.exceptions.RequestException as e:
except requests.exceptions.RequestException:
print(colored("No se pueden encontrar los paquetes. Revise su conexión a internet e inténtelo de nuevo más tarde.", 'red'))
sys.exit(1)

Expand Down Expand Up @@ -103,7 +99,13 @@ def download_and_install_package(package_name, retry=False):
print(colored(f"El paquete puede contener configuraciones que se instalarán ahora...", 'green'))
result = subprocess.run([install_bat_path], check=True, shell=True)
elif os.path.exists(setup_exe_path):
result = subprocess.run([setup_exe_path], check=True)
try:
result = subprocess.run([setup_exe_path], check=True)
except subprocess.CalledProcessError as e:
if e.returncode == 740: # Código de error de elevación
print(colored("Se necesita permisos de administrador para ejecutar este instalador.", 'red'))
print(colored("Ejecuta este script como administrador.", 'yellow'))
return # Termina la función
elif os.path.exists(setup_msi_path):
result = subprocess.run(["msiexec", "/i", setup_msi_path, "/quiet", "/norestart"], check=True)
else:
Expand All @@ -114,10 +116,10 @@ def download_and_install_package(package_name, retry=False):
else:
raise subprocess.CalledProcessError(result.returncode, install_bat_path if os.path.exists(install_bat_path) else (setup_exe_path if os.path.exists(setup_exe_path) else setup_msi_path))

except (requests.exceptions.RequestException, zipfile.BadZipFile) as e:
except (requests.exceptions.RequestException, zipfile.BadZipFile):
print(colored(f"Error: No se puede descargar o extraer el paquete {package_name}.", 'red'))
sys.exit(1)
except subprocess.CalledProcessError as e:
except subprocess.CalledProcessError:
print(colored(f"Ocurrió algún problema durante la instalación. Si quiere intentar instalar el programa pruebe con --retry-install", 'red'))
if not retry:
with open(RETRY_FILE_PATH, "wb") as retry_file:
Expand Down

0 comments on commit 234f12b

Please sign in to comment.