41 lines
885 B
Python
Executable File
41 lines
885 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""Unpack LocalMods.tar.gz into LocalMods/ and remove the archive."""
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
BASE = os.path.dirname(os.path.abspath(__file__))
|
|
TAR_PATH = os.path.join(BASE, "LocalMods.tar.gz")
|
|
|
|
|
|
def log_ok(msg):
|
|
print(f"\033[92m✓\033[0m {msg}")
|
|
|
|
def log_info(msg):
|
|
print(f"• {msg}")
|
|
|
|
def log_err(msg):
|
|
print(f"\033[91m✗\033[0m {msg}", file=sys.stderr)
|
|
|
|
|
|
def main():
|
|
print()
|
|
|
|
if not os.path.isfile(TAR_PATH):
|
|
log_err(f"Not found: {TAR_PATH}")
|
|
sys.exit(1)
|
|
|
|
log_info(f"Extracting: {TAR_PATH}")
|
|
subprocess.run(["tar", "-xzf", TAR_PATH, "-C", BASE], check=True)
|
|
|
|
size = os.path.getsize(TAR_PATH)
|
|
os.remove(TAR_PATH)
|
|
log_ok(f"Extracted to {os.path.join(BASE, 'LocalMods')}/")
|
|
log_ok(f"Removed archive ({size / 1024:.1f} KB freed)")
|
|
print()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|