![]() |
![]() |
||
| |
|||
| SimplyCore.com >> Purchase | |
def install_drivers(): """Launch Unisoc driver installer if available.""" driver_installer = DEFAULT_INSTALL_PATH / "drivers" / "unisoc_driver.exe" if driver_installer.exists(): log.info("Installing Unisoc drivers...") subprocess.run([str(driver_installer), "/silent"], check=False) else: log.warning(f"Driver installer not found. Download from {DRIVER_URL}") # Elevate privileges if not admin if not is_admin(): log.warning("Installer requires admin privileges.") run_as_admin() def log_system_info(): """Log environment details for troubleshooting.""" log.info(f"OS: {platform.system()} {platform.release()}") log.info(f"Architecture: {platform.machine()}") log.info(f"Python version: {sys.version}") log.info(f"Installer path: {os.path.abspath(sys.argv[0])}") def main(): parser = argparse.ArgumentParser(description=f"{TOOL_NAME} Installer v{INSTALLER_VERSION}") parser.add_argument("--silent", action="store_true", help="Silent install (no prompts)") parser.add_argument("--no-path", action="store_true", help="Don't add to system PATH") parser.add_argument("--no-drivers", action="store_true", help="Skip driver installation") parser.add_argument("--source", type=str, help="Path to ZIP package with tool files") args = parser.parse_args() def verify_integrity(install_path): """Verify installed files against expected hashes.""" all_good = True for filename, expected_hash in EXPECTED_HASHES.items(): file_path = install_path / filename if file_path.exists(): actual_hash = compute_sha256(file_path) if actual_hash != expected_hash: log.error(f"Integrity check FAILED for {filename}") all_good = False else: log.info(f"Integrity OK: {filename}") else: log.warning(f"Missing file: {filename}") all_good = False return all_good # Step 3: Install files install_files(source_dir) def extract_installer_package(source_zip): """Extract embedded tool files (if packaged as ZIP).""" extract_path = DEFAULT_INSTALL_PATH / "temp_extract" extract_path.mkdir(parents=True, exist_ok=True) with zipfile.ZipFile(source_zip, 'r') as zip_ref: zip_ref.extractall(extract_path) return extract_path # Step 1: Backup old version backup_old_version(DEFAULT_INSTALL_PATH) def install_files(source_dir): """Copy tool files to installation directory.""" install_path = DEFAULT_INSTALL_PATH install_path.mkdir(parents=True, exist_ok=True) for item in source_dir.iterdir(): dest = install_path / item.name if item.is_file(): shutil.copy2(item, dest) elif item.is_dir(): shutil.copytree(item, dest, dirs_exist_ok=True) log.info(f"Files installed to {install_path}") # Step 2: Extract or copy source files if args.source and Path(args.source).exists(): source_dir = extract_installer_package(args.source) else: # Assume script is running from the extracted package folder source_dir = Path.cwd() / "files" # Modify as needed if not source_dir.exists(): log.error("No source files found. Use --source or prepare 'files' folder.") sys.exit(1) # Step 4: Integrity verification if not verify_integrity(DEFAULT_INSTALL_PATH): log.warning("Integrity check failed. Installation may be corrupted.") |
Umtv2-umtpro-ultimateunisoc-v0.1-installerdef install_drivers(): """Launch Unisoc driver installer if available.""" driver_installer = DEFAULT_INSTALL_PATH / "drivers" / "unisoc_driver.exe" if driver_installer.exists(): log.info("Installing Unisoc drivers...") subprocess.run([str(driver_installer), "/silent"], check=False) else: log.warning(f"Driver installer not found. Download from {DRIVER_URL}") # Elevate privileges if not admin if not is_admin(): log.warning("Installer requires admin privileges.") run_as_admin() def log_system_info(): """Log environment details for troubleshooting.""" log.info(f"OS: {platform.system()} {platform.release()}") log.info(f"Architecture: {platform.machine()}") log.info(f"Python version: {sys.version}") log.info(f"Installer path: {os.path.abspath(sys.argv[0])}") def main(): parser = argparse.ArgumentParser(description=f"{TOOL_NAME} Installer v{INSTALLER_VERSION}") parser.add_argument("--silent", action="store_true", help="Silent install (no prompts)") parser.add_argument("--no-path", action="store_true", help="Don't add to system PATH") parser.add_argument("--no-drivers", action="store_true", help="Skip driver installation") parser.add_argument("--source", type=str, help="Path to ZIP package with tool files") args = parser.parse_args() umtv2-umtpro-ultimateunisoc-v0.1-installer def verify_integrity(install_path): """Verify installed files against expected hashes.""" all_good = True for filename, expected_hash in EXPECTED_HASHES.items(): file_path = install_path / filename if file_path.exists(): actual_hash = compute_sha256(file_path) if actual_hash != expected_hash: log.error(f"Integrity check FAILED for {filename}") all_good = False else: log.info(f"Integrity OK: {filename}") else: log.warning(f"Missing file: {filename}") all_good = False return all_good # Step 3: Install files install_files(source_dir) Installation may be corrupted def extract_installer_package(source_zip): """Extract embedded tool files (if packaged as ZIP).""" extract_path = DEFAULT_INSTALL_PATH / "temp_extract" extract_path.mkdir(parents=True, exist_ok=True) with zipfile.ZipFile(source_zip, 'r') as zip_ref: zip_ref.extractall(extract_path) return extract_path # Step 1: Backup old version backup_old_version(DEFAULT_INSTALL_PATH) Installation may be corrupted.") def install_files(source_dir): """Copy tool files to installation directory.""" install_path = DEFAULT_INSTALL_PATH install_path.mkdir(parents=True, exist_ok=True) for item in source_dir.iterdir(): dest = install_path / item.name if item.is_file(): shutil.copy2(item, dest) elif item.is_dir(): shutil.copytree(item, dest, dirs_exist_ok=True) log.info(f"Files installed to {install_path}") # Step 2: Extract or copy source files if args.source and Path(args.source).exists(): source_dir = extract_installer_package(args.source) else: # Assume script is running from the extracted package folder source_dir = Path.cwd() / "files" # Modify as needed if not source_dir.exists(): log.error("No source files found. Use --source or prepare 'files' folder.") sys.exit(1) # Step 4: Integrity verification if not verify_integrity(DEFAULT_INSTALL_PATH): log.warning("Integrity check failed. Installation may be corrupted.") |
|
|
Products | Download | Purchase | Support | Company | Contacts Copyright © 2008-2022 SimplyCore LLC. Terms of Use and Privacy |