Skip to content

Commit 7158add

Browse files
use os.popen to read stdout
1 parent 373ecf3 commit 7158add

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

utils/info.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
from funs import *
33

44
######## VNC
5-
if os.system("hostname -I | cut -d \" \" -f 2") is None:
6-
IPv4Address = os.system("hostname -I")
5+
if os.popen("hostname -I | cut -d \" \" -f 2 | tr -d '\\n'").read() is '':
6+
# hostname returs \n which can effect logic
7+
IPv4Address = os.popen("hostname -I | tr -d '\\n'").read().strip()
78
else:
8-
IPv4Address = os.system("hostname -I | cut -d \" \" -f 2")
9+
IPv4Address = os.popen("hostname -I | cut -d \" \" -f 2 | tr -d '\\n'").read().strip()
910

1011
LOCALIP="127.0.0.1"
1112

@@ -24,3 +25,5 @@ def vncrunningdialog(port):
2425
+"\n"+"To stop it, run:\n"\
2526
+green("vncserver -kill :"+str(port))\
2627
+" or "+blue("stopvnc")
28+
29+
print(vncokdialog(5900))

0 commit comments

Comments
 (0)