gateway: Fix SSH-error after run "reboot" command

pull/36/head
remittor 6 months ago
parent 168878255b
commit f4f8a148d7

@ -901,7 +901,7 @@ class Gateway():
return False
return True
def run_cmd(self, command, msg = None, timeout = None, die_on_error = True):
def run_cmd(self, command, msg = None, timeout = None, die_on_error = True, reboot = False):
error = 0
reslist = [ ]
self.errcode = -1
@ -938,6 +938,10 @@ class Gateway():
except Exception as e:
error = -10
finally:
if reboot:
self.shutdown()
self.errcode = 0
return ''
channel.close()
channel.wait_closed()
if error != 0 and die_on_error:

@ -1116,12 +1116,8 @@ class XqFlash():
else:
import ssh2
print('Send command "reboot" via SSH/Telnet ...')
try:
gw.run_cmd("reboot -f", die_on_error = False)
print("Forced REBOOT activated!")
except ssh2.exceptions.SocketRecvError as e:
print("Forced REBOOT Activated!")
pass
gw.run_cmd("reboot -f", die_on_error = False, reboot = True)
print("Forced REBOOT activated!")
def flash_data_to_mtd(self, img_name, img: Image, timeout, check = True):
print(f'Writing {img_name} image to addr 0x{img.addr:08X} ...')

@ -3,6 +3,7 @@
import os
import sys
import time
import platform
import xmir_base
@ -15,7 +16,8 @@ gw = gateway.Gateway(detect_ssh = False)
ssh = gw.detect_ssh(verbose = 1, interactive = True)
if ssh > 0:
print('Send command "reboot" via SSH ...')
gw.run_cmd("reboot")
gw.run_cmd("reboot", reboot = True)
time.sleep(1)
else:
if not gw.stok:
gw.web_login()

Loading…
Cancel
Save