Update zrok.py
Browse files
zrok.py
CHANGED
|
@@ -1,49 +1,34 @@
|
|
| 1 |
-
from multiprocessing import Process
|
| 2 |
-
import subprocess
|
| 3 |
-
import sys
|
| 4 |
-
import re
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
if __name__ == '__main__':
|
| 37 |
-
if len(sys.argv) != 2:
|
| 38 |
-
sys.exit("")
|
| 39 |
-
|
| 40 |
-
zrok_out = Queue()
|
| 41 |
-
|
| 42 |
-
process = Process(target=hitozuma, args=(sys.argv[1], zrok_out))
|
| 43 |
-
process.start()
|
| 44 |
-
|
| 45 |
-
while process.is_alive() or not zrok_out.empty():
|
| 46 |
-
while not zrok_out.empty():
|
| 47 |
-
print(zrok_out.get(), end='', flush=True)
|
| 48 |
-
|
| 49 |
-
process.join()
|
|
|
|
| 1 |
+
from multiprocessing import Process ,Queue #line:1
|
| 2 |
+
import subprocess #line:2
|
| 3 |
+
import sys #line:3
|
| 4 |
+
import re #line:4
|
| 5 |
+
def hitozuma (OOOOO0OOOOOOOO0OO ,OO000OOO0OOOO000O ):#line:6
|
| 6 |
+
try :#line:7
|
| 7 |
+
OO0OOOO0O00O0O000 =subprocess .run (['/home/studio-lab-user/.zrok/bin/zrok','enable',OOOOO0OOOOOOOO0OO ],check =False ,stdout =subprocess .PIPE ,stderr =subprocess .STDOUT ,text =True )#line:9
|
| 8 |
+
O00O0OO00000OO00O =subprocess .Popen (["/home/studio-lab-user/.zrok/bin/zrok","share","public","localhost:7860","--headless"],stdout =subprocess .PIPE ,stderr =subprocess .STDOUT ,text =True )#line:12
|
| 9 |
+
OOO00OOO00000O0O0 =re .compile (r'https?://[^\s]*\.zrok\.io')#line:14
|
| 10 |
+
O0O00O0O00OOO0OOO =("◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼")#line:15
|
| 11 |
+
if OO0OOOO0O00O0O000 .returncode ==0 :#line:17
|
| 12 |
+
OO000OOO0OOOO000O .put (f"\n{O0O00O0O00OOO0OOO}\n[ZROK] 环境启用.\n")#line:18
|
| 13 |
+
else :#line:20
|
| 14 |
+
if "enabled environment"in OO0OOOO0O00O0O000 .stdout :#line:21
|
| 15 |
+
OO000OOO0OOOO000O .put (f"\n{O0O00O0O00OOO0OOO}\n[ZROK] 环境已经启用.\n")#line:22
|
| 16 |
+
else :#line:23
|
| 17 |
+
OO000OOO0OOOO000O .put (OO0OOOO0O00O0O000 .stdout )#line:24
|
| 18 |
+
for OOOO00OOO00O0OO00 in O00O0OO00000OO00O .stdout :#line:26
|
| 19 |
+
OOOOO00O00OO0000O =OOO00OOO00000O0O0 .findall (OOOO00OOO00O0OO00 )#line:27
|
| 20 |
+
for O00OOO0O0O0O0OO00 in OOOOO00O00OO0000O :#line:28
|
| 21 |
+
OO000OOO0OOOO000O .put (f"[ZROK] {O00OOO0O0O0O0OO00}\n{O0O00O0O00OOO0OOO}\n\n")#line:29
|
| 22 |
+
O00O0OO00000OO00O .wait ()#line:31
|
| 23 |
+
except :#line:33
|
| 24 |
+
pass #line:34
|
| 25 |
+
if __name__ =='__main__':#line:36
|
| 26 |
+
if len (sys .argv )!=2 :#line:37
|
| 27 |
+
sys .exit ("")#line:38
|
| 28 |
+
zrok_out =Queue ()#line:40
|
| 29 |
+
process =Process (target =hitozuma ,args =(sys .argv [1 ],zrok_out ))#line:42
|
| 30 |
+
process .start ()#line:43
|
| 31 |
+
while process .is_alive ()or not zrok_out .empty ():#line:45
|
| 32 |
+
while not zrok_out .empty ():#line:46
|
| 33 |
+
print (zrok_out .get (),end ='',flush =True )#line:47
|
| 34 |
+
process .join ()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|