mirror of
https://gitlab.sectorq.eu/jaydee/python.git
synced 2025-12-13 18:24:53 +01:00
added update
This commit is contained in:
@@ -14,9 +14,9 @@ import ctypes
|
||||
import getopt
|
||||
import requests
|
||||
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:
|
||||
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:
|
||||
# print help information and exit:
|
||||
print(str(err)) # will print something like "option -a not recognized"
|
||||
@@ -36,6 +36,8 @@ for o, a in opts:
|
||||
_WIFI_SETUP = True
|
||||
elif o in ("-a", "--apply"):
|
||||
_APPLY = True
|
||||
elif o in ("-u", "--upgrade_fw"):
|
||||
_UPGRADE_FW = True
|
||||
else:
|
||||
_WIZZARD = True
|
||||
|
||||
@@ -90,7 +92,41 @@ def create_backup():
|
||||
#print(sys_ip + " : Not a listening")
|
||||
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():
|
||||
SSID1 = input(">> SID1 ? (default=jaydee) : ") or "jaydee"
|
||||
PASS1 = input(">> PASS1 ? (default=) : ") or ""
|
||||
@@ -169,4 +205,8 @@ if _MQTT_SETUP:
|
||||
mqtt_setup()
|
||||
|
||||
if _WIFI_SETUP:
|
||||
wifi_setup()
|
||||
wifi_setup()
|
||||
|
||||
|
||||
if _UPGRADE_FW:
|
||||
upgrade_fw()
|
||||
Reference in New Issue
Block a user