[youtube]https://youtu.be/bo8X5rsZ-Lw[/youtube]

I read all of this viewtopic.php?t=1965 and used goteamscotch script as a starting point. and ended up here
Code: Select all
import xbmc, xbmcgui, time
import sys
import telnetlib
dialog = xbmcgui.Dialog()
dprogress = xbmcgui.DialogProgress()
host = "192.168.0.25"
tn = telnetlib.Telnet(host, 23)
#Telnet.set_debuglevel (1)
scan_results = tn.read_until("OpenWrt:/#")
#time.sleep(1)
tn.write("Scanning\n")
#time.sleep(1)
scan_results = tn.read_until("Enter")
ACTION_PREVIOUS_MENU = 10
ACTION_SELECT_ITEM = 7
class openwrt(xbmcgui.Window):
def __init__(self):
self.addControl(xbmcgui.ControlImage(0,0,1280,720, 'background.png'))
self.strActionInfo = xbmcgui.ControlLabel(326,82,720,480, '', 'font13', '0xFF00FF00')
self.addControl(self.strActionInfo)
self.strActionInfo.setLabel('scan_results')
self.button1 = xbmcgui.ControlButton(240, 134, 80, 30, "No1")
self.addControl(self.button1)
self.setFocus(self.button1)
def onAction(self, action):
if action == ACTION_PREVIOUS_MENU:
self.confirmexit()
if action == ACTION_SELECT_ITEM:
self.No()
def confirmexit(self):
dialog = xbmcgui.Dialog()
if dialog.yesno("Confirm", "Are you sure you want to quit?"):
self.close()
import telnetlib
host = "192.168.0.25"
tn = telnetlib.Telnet(host, 23)
self.tn.write("exit\n")
tn.write("exit\n")
self.tn.write("reboot\n")
tn.write("reboot\n")
# def No1(
# self.button2 = xbmcgui.ControlButton(240, 164, 80, 30, "No2")
# self.addControl(self.button2)
# self.setFocus(self.button2)
# self.button3 = xbmcgui.ControlButton(240, 194, 80, 30, "No3")
# self.addControl(self.button3)
# self.setFocus(self.button3)
# self.button4 = xbmcgui.ControlButton(240, 224, 80, 30, "No4")
# self.addControl(self.button4)
# self.setFocus(self.button4)
# self.button5 = xbmcgui.ControlButton(240, 254, 80, 30, "No5")
# self.addControl(self.button5)
# self.setFocus(self.button5)
# self.button6 = xbmcgui.ControlButton(240, 284, 80, 30, "No6")
# self.addControl(self.button6)
# self.setFocus(self.button6)
# self.button7 = xbmcgui.ControlButton(240, 314, 80, 30, "No7")
# self.addControl(self.button7)
# self.setFocus(self.button7)
# self.button8 = xbmcgui.ControlButton(240, 344, 80, 30, "No8")
# self.addControl(self.button8)
# self.setFocus(self.button8)
# self.button9 = xbmcgui.ControlButton(240, 374, 80, 30, "No9")
# self.addControl(self.button9)
# self.setFocus(self.button9)
# self.button10 = xbmcgui.ControlButton(240, 404, 80, 30, "No10")
# self.addControl(self.button10)
# self.setFocus(self.button10)
#def No10(self):
# self.strActionInfo = xbmcgui.ControlLabel(100, 300, 300, 800, '', 'font13', '0xFFFFFFFF')
# self.addControl(self.strActionInfo)#(0,0,720,480, 'Q:\\scripts\\background.jpg'))
# keyboard = xbmc.Keyboard('password')
# keyboard.doModal()
# if (keyboard.isConfirmed()):
# self.strActionInfo.setLabel(keyboard.getText())
# else:
# self.strActionInfo.setLabel('user canceled')
#scan_results = tn.read_until("OpenWrt:/#")#, timeout = 10)
#time.sleep(1)
#tn.write("exit\n")
#self.tn.write("exit\n")
#self.tn.write("exit\n")
#tn.expect("networks:", timeout = 5)
#scan_results = tn.read_until("OpenWrt:/#")
#scan_results = tn.read_lazy(timeout = 5)
# def onControl(self, control):
# if control == self.button10:
# self.No10()
#def No1(self):
# host = "192.168.0.25"
# tn = telnetlib.Telnet(host, 23)
# self.tn.write ("exit\n")
# self.tn.write ("exit\n")
# tn.read_untill("network:")
# tn.write("password\n")
# scan_results = tn.read_all()
# def onControl(self, control):
# if control == self.button1:
# self.No1()
# def No2(self):
# if dialog.yesno("No2", "connect?"):
# self.tn.write("2\n")
# if network:
# tn.read_untill("network")
# tn.write(keyboard + "\n")
# def onControl(self, control):
# if control == self.button2:
# self.No2()
# def No3(self):
# dialog = xbmcgui.Dialog()
# if dialog.yesno("No3", "connect?"):
# self.tn.write("3\n")
# if network:
# tn.read_untill("network")
# tn.write(keyboard + "\n")
# def onControl(self, control):
# if control == self.button3:
# self.No3()
# def No4(self):
# dialog = xbmcgui.Dialog()
# if dialog.yesno("No4", "connect?"):
# self.tn.write("4\n")
# if network:
# tn.read_untill("network")
# tn.write(keyboard + "\n")
# def onControl(self, control):
# if control == self.button4:
# self.No4()
# def No5(self):
# dialog = xbmcgui.Dialog()
# if dialog.yesno("No5", "connect?"):
# self.tn.write("5\n")
# if network:
# tn.read_untill("network")
# tn.write(keyboard + "\n")
# def onControl(self, control):
# if control == self.button5:
# self.No5()
#
# def No6(self):
# dialog = xbmcgui.Dialog()
# if dialog.yesno("No6", "connect?"):
# self.tn.write("6\n")
# if network:
# tn.read_untill("network")
# tn.write(keyboard + "\n")
# def onControl(self, control):
# if control == self.button6:
# self.No6()
#
# def No7(self):
# dialog = xbmcgui.Dialog()
# if dialog.yesno("No7", "connect?"):
# self.tn.write("7\n")
# if network:
# tn.read_untill("network")
# tn.write(keyboard + "\n")
# def onControl(self, control):
# if control == self.button7:
# self.No7()
#
# def No8(self):
# dialog = xbmcgui.Dialog()
# if dialog.yesno("No8", "connect?"):
# self.tn.write("8\n")
# if network:
# tn.read_untill("network")
# tn.write(keyboard + "\n")
# def onControl(self, control):
# if control == self.button8:
# self.No8()
#
# def No9(self):
# dialog = xbmcgui.Dialog()
# if dialog.yesno("No9", "connect?"):
# self.tn.write("9\n")
# if network:
# tn.read_untill("network")
# tn.write(keyboard + "\n")
# def onControl(self, control):
# if control == self.button9:
# self.No9()
#
# def onControl(self, control):
# if control == self.button10:
# self.No10()
#def onAction(self, action):
# if action == ACTION_PREVIOUS_MENU:
# self.confirmexit()
#def confirmexit(self):
# dialog = xbmcgui.Dialog()
# if dialog.yesno("Confirm", "Are you sure you want to quit?"):
# self.close()
mydisplay = openwrt()
mydisplay.strActionInfo.setLabel(scan_results)
mydisplay .doModal()
del mydisplay