gmk123 commited on
Commit
76da02c
·
verified ·
1 Parent(s): a6f52b8

Update zrok.py

Browse files
Files changed (1) hide show
  1. zrok.py +34 -49
zrok.py CHANGED
@@ -1,49 +1,34 @@
1
- from multiprocessing import Process, Queue
2
- import subprocess
3
- import sys
4
- import re
5
-
6
- def hitozuma(token, zrok_out):
7
- try:
8
- oppai = subprocess.run(['/home/studio-lab-user/.zrok/bin/zrok', 'enable', token],
9
- check=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
10
-
11
- ass = subprocess.Popen(["/home/studio-lab-user/.zrok/bin/zrok", "share", "public", "localhost:7860", "--headless"],
12
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
13
-
14
- urlp = re.compile(r'https?://[^\s]*\.zrok\.io')
15
- asu = ("◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼")
16
-
17
- if oppai.returncode == 0:
18
- zrok_out.put(f"\n{asu}\n[ZROK] environment enabled.\n")
19
-
20
- else:
21
- if "enabled environment" in oppai.stdout:
22
- zrok_out.put(f"\n{asu}\n[ZROK] environment already enabled.\n")
23
- else:
24
- zrok_out.put(oppai.stdout)
25
-
26
- for line in ass.stdout:
27
- urls = urlp.findall(line)
28
- for url in urls:
29
- zrok_out.put(f"[ZROK] {url}\n{asu}\n\n")
30
-
31
- ass.wait()
32
-
33
- except:
34
- pass
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 ()