From 6b6c203ad5b4855eae18ff3a4667a67f74a9a82f Mon Sep 17 00:00:00 2001 From: kos Date: Wed, 17 Jul 2013 16:26:13 +0900 Subject: [PATCH] [wol] show the mac-addr on plugin screen. --- .../Plugins/SystemPlugins/WOLSetup/plugin.py | 28 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/python/Plugins/SystemPlugins/WOLSetup/plugin.py b/lib/python/Plugins/SystemPlugins/WOLSetup/plugin.py index 9beb993..1276b1e 100644 --- a/lib/python/Plugins/SystemPlugins/WOLSetup/plugin.py +++ b/lib/python/Plugins/SystemPlugins/WOLSetup/plugin.py @@ -29,6 +29,21 @@ config.plugins.wolconfig = ConfigSubsection() config.plugins.wolconfig.activate = ConfigYesNo(default = False) config.plugins.wolconfig.location = ConfigSelection(default = "menu", choices = [("menu", _("Show on the Standby Menu")), ("deepstandby", _("Run at the Deep Standby"))]) +import socket +class NetTool: + @staticmethod + def GetHardwareAddr(ethname): + macaddr = "" + try: + sock = socket.socket(socket.AF_PACKET, socket.SOCK_RAW) + sock.bind((ethname, 9999)) + + macaddr = ":".join(["%02X" % ord(x) for x in sock.getsockname()[-1]]) + except Exception, Message: + print Message + macaddr = "Unknown" + return macaddr + class WOLSetup(ConfigListScreen, Screen): skin = """ @@ -42,8 +57,8 @@ class WOLSetup(ConfigListScreen, Screen): - - + + """ def __init__(self, session): @@ -63,8 +78,7 @@ class WOLSetup(ConfigListScreen, Screen): self["key_green"] = StaticText(_("Save")) self["key_yellow"] = StaticText(_(" ")) self["key_blue"] = StaticText(_("Default")) - - self["introduction"] = Label(_(" ")) + self["introduction"] = Label(" ") self.default = {"activate":False, "location":"menu"} self.backup = { @@ -80,9 +94,13 @@ class WOLSetup(ConfigListScreen, Screen): def UpdateConfigList(self): self.configlist = [] if _flagSupportWol: + macaddr = " " self.configlist.append(getConfigListEntry(_("WakeOnLan Enable"), config.plugins.wolconfig.activate)) if config.plugins.wolconfig.activate.value: - self.configlist.append(getConfigListEntry(_(" - Location"), config.plugins.wolconfig.location)) + self.configlist.append(getConfigListEntry(_("Location"), config.plugins.wolconfig.location)) + macaddr = "HWaddr of %s is %s" % (_ethDevice, NetTool.GetHardwareAddr(_ethDevice)) + else: macaddr = "Wake on Lan disabled" + self["introduction"].setText(macaddr) self["config"].list = self.configlist self["config"].l.setList(self.configlist) -- 2.7.4