Category:Teclast/gcollab mtk
Appearance
https://colab.research.google.com
This script repacks firmware into individually compressed files
import os import subprocess import shutil from google.colab import drive !wget -O firmware.rar "https://my.microsoftpersonalcontent.com/personal/1f4f57e2d1002667/_layouts/15/download.aspx?UniqueId=d1002667-57e2-204f-801f-a11100000000&Translate=false&tempauth=v1e.eyJzaXRlaWQiOiIwMjUzOTBjMS0yZTQ1LTRlODctYjY2MS1jODRjY2M4MzNlNmIiLCJhcHBpZCI6IjAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDA0ODE3MTBhNCIsImF1ZCI6IjAwMDAwMDAzLTAwMDAtMGZmMS1jZTAwLTAwMDAwMDAwMDAwMC9teS5taWNyb3NvZnRwZXJzb25hbGNvbnRlbnQuY29tQDkxODgwNDBkLTZjNjctNGM1Yi1iMTEyLTM2YTMwNGI2NmRhZCIsImV4cCI6IjE3NDYyNjU5MzYifQ.WQvWIgyXqqFeaFstn4FpYiAWjXPFBaxeFt0akBIkGa1recYpJPX3jchL3sZWK_m-ozVmI8AoHEHuvu1c8ps1ARPtMRBcs3nvIS1JNSfNhy-fSUtBXjN_SYwBt_2kiSLBW9L9N_--W_0-derVbhsqGgx4EVuNJjxJ-320GCp5Iv92T20lFNm18rpR_g8Ags0uYVleYLvet1wddqWSm9Erj1DLJ1IOPCHUFo3wFVS-wjme__51aKWu4NWWIL0LSP-WdfrLrRmG9X0zEEG2rTBoqOkou56kRguMpYdYLDP34HxrVsOp0l9vP3XBdaLmalGQG8JkKj3Em8muhT1R4-JAwe5AGAa-gB7UajwjYREG0vkOMIYTi9BZq2nsb_dugJT-FCm-22EBIkY-FBPPSFt-kw.2ydRBxkwupnB8wR1hfKFSTeSa2htypziv0rPxZdoZEU&ApiVersion=2.0" !unrar x /content/firmware.rar # Mount Google Drive drive.mount('/content/drive') # Install zstd if not already installed subprocess.run(["apt", "install", "-y", "zstd"], check=True) # Define the source and destination directories firmware_dir = "/content/Firmware" # Assuming firmware files are extracted here output_dir = "/content/drive/MyDrive/Shared/output_dir" # Output directory in Google Drive # Create the output directory if it doesn't exist if not os.path.exists(output_dir): os.makedirs(output_dir) # Loop through each file in the firmware directory for filename in os.listdir(firmware_dir): source_path = os.path.join(firmware_dir, filename) if os.path.isfile(source_path): # Ensure it's a file, not a subdirectory destination_path = os.path.join(output_dir, filename + ".zst") # Use zstd command to compress the file with progress try: subprocess.run( ["zstd", "-22", "--ultra", "-T0", "-k", "-v", source_path], check=True ) # Move the compressed file to Google Drive using shutil.move() shutil.move(source_path + ".zst", destination_path) print(f"Compressed and moved: {filename}") except subprocess.CalledProcessError as e: print(f"Error compressing {filename}: {e}") except FileNotFoundError: print("zstd command not found. Make sure zstd is installed.") break # Stop processing if zstd is not found
This category currently contains no pages or media.