mirror of
https://gitlab.sectorq.eu/jaydee/python.git
synced 2025-12-14 02:34:53 +01:00
added update
This commit is contained in:
@@ -14,9 +14,9 @@ import ctypes
|
|||||||
import getopt
|
import getopt
|
||||||
import requests
|
import requests
|
||||||
CHECK_MARK = "\033[0;32m\xE2\x9C\x94\033[0m"
|
CHECK_MARK = "\033[0;32m\xE2\x9C\x94\033[0m"
|
||||||
_MQTT_SETUP = _BACKUP = _APPLY = _WIFI_SETUP = False
|
_MQTT_SETUP = _BACKUP = _APPLY = _WIFI_SETUP = _UPGRADE_FW = False
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], "wh:bm", ["command=", "help", "output=", "backup"])
|
opts, args = getopt.getopt(sys.argv[1:], "wh:bmu", ["command=", "help", "output=", "backup"])
|
||||||
except getopt.GetoptError as err:
|
except getopt.GetoptError as err:
|
||||||
# print help information and exit:
|
# print help information and exit:
|
||||||
print(str(err)) # will print something like "option -a not recognized"
|
print(str(err)) # will print something like "option -a not recognized"
|
||||||
@@ -36,6 +36,8 @@ for o, a in opts:
|
|||||||
_WIFI_SETUP = True
|
_WIFI_SETUP = True
|
||||||
elif o in ("-a", "--apply"):
|
elif o in ("-a", "--apply"):
|
||||||
_APPLY = True
|
_APPLY = True
|
||||||
|
elif o in ("-u", "--upgrade_fw"):
|
||||||
|
_UPGRADE_FW = True
|
||||||
else:
|
else:
|
||||||
_WIZZARD = True
|
_WIZZARD = True
|
||||||
|
|
||||||
@@ -90,6 +92,40 @@ def create_backup():
|
|||||||
#print(sys_ip + " : Not a listening")
|
#print(sys_ip + " : Not a listening")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def upgrade_fw():
|
||||||
|
cmnd = "nmap -sP 192.168.77.*|grep \"Nmap scan report\"|egrep -o \"[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\""
|
||||||
|
#print(cmnd)
|
||||||
|
status, output = subprocess.getstatusoutput(cmnd)
|
||||||
|
|
||||||
|
# print(output)
|
||||||
|
|
||||||
|
ips = output.splitlines()
|
||||||
|
for sys_ip in ips:
|
||||||
|
print("Thsis is ip : " + sys_ip)
|
||||||
|
cmnd = "nmap " + sys_ip + " -p80|grep \"80/tcp open http\""
|
||||||
|
status, output = subprocess.getstatusoutput(cmnd)
|
||||||
|
# print("status of 80 : " + str(status))
|
||||||
|
if status == 0:
|
||||||
|
try:
|
||||||
|
# url = "http://" + sys_ip + "/cm?user=admin&password=l4c1j4yd33Du5l0&cmnd=STATUS+5"
|
||||||
|
|
||||||
|
url = "http://" + sys_ip + "/cm?user=admin&password=l4c1j4yd33Du5l0&cmnd=STATUS+1"
|
||||||
|
#print(url)
|
||||||
|
resp = requests.get(url)
|
||||||
|
json_str = resp.content.decode('utf-8')
|
||||||
|
#print(json_str)
|
||||||
|
tasm_data = json.loads(json_str)
|
||||||
|
#print(tasm_data)
|
||||||
|
print(tasm_data["StatusPRM"]["OtaUrl"])
|
||||||
|
|
||||||
|
|
||||||
|
except:
|
||||||
|
#print(sys_ip + " : Not a tasmota!")
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
#print(sys_ip + " : Not a listening")
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def wifi_setup():
|
def wifi_setup():
|
||||||
SSID1 = input(">> SID1 ? (default=jaydee) : ") or "jaydee"
|
SSID1 = input(">> SID1 ? (default=jaydee) : ") or "jaydee"
|
||||||
@@ -170,3 +206,7 @@ if _MQTT_SETUP:
|
|||||||
|
|
||||||
if _WIFI_SETUP:
|
if _WIFI_SETUP:
|
||||||
wifi_setup()
|
wifi_setup()
|
||||||
|
|
||||||
|
|
||||||
|
if _UPGRADE_FW:
|
||||||
|
upgrade_fw()
|
||||||
Reference in New Issue
Block a user