From b7b2a5852ffc801851cc57dd3e04153468a4dd9f Mon Sep 17 00:00:00 2001 From: saicharankandukuri Date: Tue, 12 Apr 2022 09:14:51 +0530 Subject: [PATCH 1/8] #5 show ipv4 address show ipv4 address of device after starting vnc --- utils/info.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/utils/info.py b/utils/info.py index 2ac29c0..69bbb09 100644 --- a/utils/info.py +++ b/utils/info.py @@ -1,14 +1,15 @@ -import os +from ipaddress import IPv4Address +import os, socket from utils.funs import * ######## VNC -HOSTPUBIP=os.system("hostname -I | cut -d ' ' -f 2") +IPv4Address=socket.gethostbyname(socket.gethostname()) LOCALIP="127.0.0.1" def vncokdialog(port): return "vncserver started on "\ +"\n"+magneta(str(LOCALIP)+":"+str(port))\ - +"\n"+magneta(str(LOCALIP)+":"+str(port))\ + +"\n"+magneta(str(IPv4Address)+":"+str(port))\ +"\n"+"To stop it, run:\n"\ +green("vncserver -kill :"+str(port))\ +" or "+blue("stopvnc") @@ -16,7 +17,7 @@ def vncokdialog(port): def vncrunningdialog(port): return "vncserver already started on "\ +"\n"+magneta(str(LOCALIP)+":"+str(port))\ - +"\n"+magneta(str(LOCALIP)+":"+str(port))\ + +"\n"+magneta(str(IPv4Address)+":"+str(port))\ +"\n"+"To stop it, run:\n"\ +green("vncserver -kill :"+str(port))\ +" or "+blue("stopvnc") From 32505a86fe66770945e062f73aec0de71ca9b585 Mon Sep 17 00:00:00 2001 From: saicharankandukuri Date: Tue, 12 Apr 2022 10:05:28 +0530 Subject: [PATCH 2/8] remove unused import --- utils/info.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/utils/info.py b/utils/info.py index 69bbb09..fca6c0f 100644 --- a/utils/info.py +++ b/utils/info.py @@ -1,6 +1,5 @@ -from ipaddress import IPv4Address -import os, socket -from utils.funs import * +import socket +from funs import * ######## VNC IPv4Address=socket.gethostbyname(socket.gethostname()) @@ -22,3 +21,8 @@ def vncrunningdialog(port): +green("vncserver -kill :"+str(port))\ +" or "+blue("stopvnc") +print(vncokdialog(5900)) +print(IPv4Address) +print(socket.gethostbyname(socket.gethostname())) + + From 8b8aa8e1498eb67573226b4aa42d16c9d48ef7eb Mon Sep 17 00:00:00 2001 From: saicharankandukuri Date: Tue, 12 Apr 2022 10:05:55 +0530 Subject: [PATCH 3/8] remove test functions --- utils/info.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/utils/info.py b/utils/info.py index fca6c0f..f31998b 100644 --- a/utils/info.py +++ b/utils/info.py @@ -20,9 +20,3 @@ def vncrunningdialog(port): +"\n"+"To stop it, run:\n"\ +green("vncserver -kill :"+str(port))\ +" or "+blue("stopvnc") - -print(vncokdialog(5900)) -print(IPv4Address) -print(socket.gethostbyname(socket.gethostname())) - - From 71dc689315f8901627cee114cf3eaccce8a98d49 Mon Sep 17 00:00:00 2001 From: saicharankandukuri Date: Tue, 12 Apr 2022 10:07:40 +0530 Subject: [PATCH 4/8] use `hostname` to get IPv4 address --- utils/info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/info.py b/utils/info.py index f31998b..bfac656 100644 --- a/utils/info.py +++ b/utils/info.py @@ -1,8 +1,8 @@ -import socket +import os from funs import * ######## VNC -IPv4Address=socket.gethostbyname(socket.gethostname()) +IPv4Address=os.system("hostname -I | cut -d \" \" -f 2") LOCALIP="127.0.0.1" def vncokdialog(port): From 373ecf31e1716d18abaf5d542aeecf63388b4b79 Mon Sep 17 00:00:00 2001 From: saicharankandukuri Date: Tue, 12 Apr 2022 10:10:30 +0530 Subject: [PATCH 5/8] conditional in case hostname -I just returns IPV4 address fallback to feild 0 --- utils/info.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/utils/info.py b/utils/info.py index bfac656..a241c40 100644 --- a/utils/info.py +++ b/utils/info.py @@ -2,7 +2,11 @@ from funs import * ######## VNC -IPv4Address=os.system("hostname -I | cut -d \" \" -f 2") +if os.system("hostname -I | cut -d \" \" -f 2") is None: + IPv4Address = os.system("hostname -I") +else: + IPv4Address = os.system("hostname -I | cut -d \" \" -f 2") + LOCALIP="127.0.0.1" def vncokdialog(port): From 7158addc184b7beeb223715eeff96f550bdf8ba0 Mon Sep 17 00:00:00 2001 From: saicharankandukuri Date: Tue, 12 Apr 2022 10:40:05 +0530 Subject: [PATCH 6/8] use os.popen to read stdout --- utils/info.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/utils/info.py b/utils/info.py index a241c40..895ea55 100644 --- a/utils/info.py +++ b/utils/info.py @@ -2,10 +2,11 @@ from funs import * ######## VNC -if os.system("hostname -I | cut -d \" \" -f 2") is None: - IPv4Address = os.system("hostname -I") +if os.popen("hostname -I | cut -d \" \" -f 2 | tr -d '\\n'").read() is '': + # hostname returs \n which can effect logic + IPv4Address = os.popen("hostname -I | tr -d '\\n'").read().strip() else: - IPv4Address = os.system("hostname -I | cut -d \" \" -f 2") + IPv4Address = os.popen("hostname -I | cut -d \" \" -f 2 | tr -d '\\n'").read().strip() LOCALIP="127.0.0.1" @@ -24,3 +25,5 @@ def vncrunningdialog(port): +"\n"+"To stop it, run:\n"\ +green("vncserver -kill :"+str(port))\ +" or "+blue("stopvnc") + +print(vncokdialog(5900)) From edbd595c8e21d480ff0d546fe51304d2dc923260 Mon Sep 17 00:00:00 2001 From: saicharankandukuri Date: Tue, 12 Apr 2022 10:41:34 +0530 Subject: [PATCH 7/8] clean up tests --- utils/info.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/utils/info.py b/utils/info.py index 895ea55..d2b401e 100644 --- a/utils/info.py +++ b/utils/info.py @@ -1,5 +1,5 @@ import os -from funs import * +from utils.funs import * ######## VNC if os.popen("hostname -I | cut -d \" \" -f 2 | tr -d '\\n'").read() is '': @@ -25,5 +25,3 @@ def vncrunningdialog(port): +"\n"+"To stop it, run:\n"\ +green("vncserver -kill :"+str(port))\ +" or "+blue("stopvnc") - -print(vncokdialog(5900)) From ca94f1e774305ecdf171d2f055e2729bab1d2e8e Mon Sep 17 00:00:00 2001 From: saicharankandukuri Date: Tue, 12 Apr 2022 10:42:46 +0530 Subject: [PATCH 8/8] increment version number --- utils/upgrade.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/upgrade.py b/utils/upgrade.py index 0390fcb..9782db0 100644 --- a/utils/upgrade.py +++ b/utils/upgrade.py @@ -1,7 +1,7 @@ import os from utils.funs import * -CURRENT_VERSION = "v0.3" +CURRENT_VERSION = "v0.4" REMOTE_VERISON = os.popen("git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/RandomCoderOrg/udroid-extra-tool-proot | tail -n1 | cut -d \"/\" -f 3").read().strip() def isold():