Transformers
Inference Endpoints
pantat88 commited on
Commit
f2f1406
1 Parent(s): a079d42

Create venv.py

Browse files
Files changed (1) hide show
  1. venv.py +98 -0
venv.py ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import select
3
+ import errno
4
+ import pty
5
+ import sys
6
+ import os
7
+ import re
8
+
9
+ xxx = "/kaggle/working"
10
+ zzz = "/kaggle/working/asd"
11
+
12
+ os.system(f'wget -q https://raw.githubusercontent.com/gutris1/segsmaker/main/kaggle/script/pantat88.py -O {xxx}/pantat88.py')
13
+ os.system(f'wget -q https://huggingface.co/pantat88/ui/resolve/main/nenen88.py -O {xxx}/nenen88.py')
14
+ sys.path.append(xxx)
15
+
16
+ def venv_in():
17
+ from pantat88 import say, download
18
+ os.chdir('/kaggle')
19
+ say('【{red} Installing VENV{d} 】{red}')
20
+ os.system('apt -y install lz4 pv aria2 > /dev/null 2>&1')
21
+ url = 'https://huggingface.co/pantat88/back_up/resolve/main/venv-1_8_0.tar.lz4'
22
+ fn = 'venv-1_8_0.tar.lz4'
23
+ fc = f"aria2c --console-log-level=error --summary-interval=1 -c -x16 -s16 -k1M -j5 '{url}' -o '{fn}'"
24
+ woiii, appaa = pty.openpty()
25
+ qqqqq = subprocess.Popen(fc, shell=True, stdin=appaa, stdout=appaa, stderr=subprocess.STDOUT, close_fds=True)
26
+ os.close(appaa)
27
+
28
+ malam = ""
29
+ while True:
30
+ r, _, _ = select.select([woiii], [], [], 0.1)
31
+ if woiii in r:
32
+ try:
33
+ petualangan = os.read(woiii, 8192).decode()
34
+ malam += petualangan
35
+ for minggu in petualangan.splitlines():
36
+ if re.match(r'\[#\w{6}\s.*\]', minggu):
37
+ sys.stdout.write("\r" + " "*80 + "\r")
38
+ sys.stdout.write(f" {minggu}")
39
+ sys.stdout.flush()
40
+ break
41
+
42
+ except OSError as e:
43
+ if e.errno == errno.EIO:
44
+ break
45
+
46
+ if qqqqq.poll() is not None and not r:
47
+ break
48
+
49
+ kemarin = malam.find("Download Results:")
50
+ if kemarin != -1:
51
+ hhhhh = malam[kemarin:]
52
+ jjjjj = hhhhh.splitlines()
53
+ kkkkk = False
54
+ for ggggg in jjjjj:
55
+ if ggggg.strip().startswith("======+====+==========="):
56
+ kkkkk = True
57
+ print("\n" + f" {ggggg}")
58
+ continue
59
+ elif ggggg.strip().startswith("Status Legend:"):
60
+ break
61
+ elif kkkkk:
62
+ print(f" {ggggg}")
63
+
64
+ qqqqq.wait()
65
+ os.close(woiii)
66
+
67
+ extract_tar = f'pv {fn} | lz4 -d | tar xf -'
68
+
69
+ ikan, asin = pty.openpty()
70
+ proc = subprocess.Popen(extract_tar, shell=True, stdin=asin, stdout=asin, stderr=asin, close_fds=True)
71
+ os.close(asin)
72
+
73
+ while True:
74
+ r, _, _ = select.select([ikan], [], [], 0.1)
75
+ if ikan in r:
76
+ try:
77
+ jemuran = os.read(ikan, 1024).decode('utf-8', 'ignore')
78
+ print(jemuran, end='')
79
+ except OSError as e:
80
+ if e.errno == errno.EIO:
81
+ break
82
+ if proc.poll() is not None:
83
+ break
84
+
85
+ proc.wait()
86
+ os.close(ikan)
87
+ os.remove(fn)
88
+
89
+ oppai = '/kaggle/venv'
90
+ os.system(f'rm -rf {os.path.join(oppai, "bin", "pip*")}')
91
+ os.system(f'rm -rf {os.path.join(oppai, "bin", "python*")}')
92
+ os.system(f'python -m venv {oppai}')
93
+ os.chdir(xxx)
94
+
95
+ if __name__ == '__main__':
96
+ venv_in()
97
+ assu = os.path.join(xxx, 'venv.py')
98
+ os.remove(assu)