import subprocess import select import errno import pty import sys import os import re xxx = "/kaggle/working" zzz = "/kaggle/working/asd" os.system(f'wget -q https://raw.githubusercontent.com/gutris1/segsmaker/main/kaggle/script/pantat88.py -O {xxx}/pantat88.py') sys.path.append(xxx) def venv_in(): from pantat88 import say os.chdir('/kaggle') say('【 {red} Installing VENV {d} 】 {red}') os.system('apt -y install lz4 pv aria2 > /dev/null 2>&1') url = 'https://huggingface.co/pantat88/back_up/resolve/main/venv-1_6_1.tar.lz4' fn = 'venv-1_6_1.tar.lz4' fc = f"aria2c --console-log-level=error --summary-interval=1 -c -x16 -s16 -k1M -j5 '{url}' -o '{fn}'" woiii, appaa = pty.openpty() qqqqq = subprocess.Popen(fc, shell=True, stdin=appaa, stdout=appaa, stderr=subprocess.STDOUT, close_fds=True) os.close(appaa) malam = "" while True: r, _, _ = select.select([woiii], [], [], 0.1) if woiii in r: try: petualangan = os.read(woiii, 8192).decode() malam += petualangan for minggu in petualangan.splitlines(): if re.match(r'\[#\w{6}\s.*\]', minggu): sys.stdout.write("\r" + " "*80 + "\r") sys.stdout.write(f" {minggu}") sys.stdout.flush() break except OSError as e: if e.errno == errno.EIO: break if qqqqq.poll() is not None and not r: break kemarin = malam.find("Download Results:") if kemarin != -1: hhhhh = malam[kemarin:] jjjjj = hhhhh.splitlines() kkkkk = False for ggggg in jjjjj: if ggggg.strip().startswith("======+====+==========="): kkkkk = True print("\n" + f" {ggggg}") continue elif ggggg.strip().startswith("Status Legend:"): break elif kkkkk: print(f" {ggggg}") qqqqq.wait() os.close(woiii) extract_tar = f'pv {fn} | lz4 -d | tar xf -' ikan, asin = pty.openpty() proc = subprocess.Popen(extract_tar, shell=True, stdin=asin, stdout=asin, stderr=asin, close_fds=True) os.close(asin) while True: r, _, _ = select.select([ikan], [], [], 0.1) if ikan in r: try: jemuran = os.read(ikan, 1024).decode('utf-8', 'ignore') print(jemuran, end='') except OSError as e: if e.errno == errno.EIO: break if proc.poll() is not None: break proc.wait() os.close(ikan) os.remove(fn) oppai = '/kaggle/venv' os.system(f'rm -rf {os.path.join(oppai, "bin", "pip*")}') os.system(f'rm -rf {os.path.join(oppai, "bin", "python*")}') os.system(f'python -m venv {oppai}') say('【 {red} Setup Completed {d} 】 {red}') if __name__ == '__main__': venv_in() assu = os.path.join(xxx, 'venv.py') os.remove(assu)