Folgende Warnungen sind aufgetreten:
Warning [2] Undefined variable $unreadreports - Line: 34 - File: global.php(961) : eval()'d code PHP 8.2.24 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/global.php(961) : eval()'d code 34 errorHandler->error_callback
/global.php 961 eval
/showthread.php 28 require_once
Warning [2] Undefined property: MyLanguage::$thread_modes - Line: 43 - File: showthread.php(1621) : eval()'d code PHP 8.2.24 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php(1621) : eval()'d code 43 errorHandler->error_callback
/showthread.php 1621 eval




Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
WifiManager
#2
Ist dein Addon universal mit xbmc.dialogen, oder wieder auf die skin von jack angewiesen?

Zu meiner python anfangszeit hatte ich dieses script für unsere skin mal geschustert:
mittlerweile würde ich einiges anders machen.:
Code:
#!/usr/bin/env python

import os
import xbmc, xbmcgui, xbmcaddon
import sys, time

# -- for skin --
# Label:    $INFO[Window(1111).Property(tether_wifi)] / $INFO[Window(1111).Property(wifi_device)]
# Bool:    !IsEmpty(Window(1111).Property(tether_wifi))
# Bool:    StringCompare(Window(1111).Property(tether_wifi),1)

bDebug = False
bWifi = False
bWifiConnected = False
bWifiTether = False


# init
def wifi_state():
   global bDebug
   global bWifi
   global bWifiConnected
   global bWifiTether

   f = os.popen("sudo connmanctl technologies")
   bWifiFound = False

   for i in f.readlines():
       # if bDebug: xbmc.executebuiltin("Notification(Tethering :" + str(i) + "," + str(len(i)) + ",2500)")
       # if bDebug: xbmcgui.Dialog().ok("connmanctl", str(i))

       if (bWifiFound and str(i).find("Type =") > 0): bWifiFound = False

       if str(i).find("Type = wifi") > 0: bWifiFound = True

       if (bWifiFound and str(i).find("Powered = True") > 0): bWifi = True
       if (bWifiFound and str(i).find("Powered = False") > 0): bWifi = False

       if (bWifiFound and str(i).find("Connected = True") > 0): bWifiConnected = True
       if (bWifiFound and str(i).find("Connected = False") > 0): bWifiConnected = False

       if (bWifiFound and str(i).find("Tethering = True") > 0): bWifiTether = True
       if (bWifiFound and str(i).find("Tethering = False") > 0): bWifiTether = False

       # get tether settings
       if (bWifiFound and str(i).find("TetheringIdentifier =") > 0):
           iTetherSSID = 24
           sTetherSSID = str(i)[iTetherSSID:-1]
           if bDebug: xbmcgui.Dialog().ok("SSID", sTetherSSID)
           xbmc.executebuiltin('Skin.SetString(wifitetherssid,' + sTetherSSID + ')')

       if (bWifiFound and str(i).find("TetheringPassphrase =") > 0):
           iTetherPW = 24
           sTetherPW = str(i)[iTetherPW:-1]
           if bDebug: xbmcgui.Dialog().ok("PW", sTetherPW)
           xbmc.executebuiltin('Skin.SetString(wifitetherpw,' + sTetherPW + ')')

   win = xbmcgui.Window(11111)

   if bWifi:
       win.setProperty('wifi_device', '1')
       if bDebug: xbmcgui.Dialog().ok("connmanctl", 'set wifi indicator true')
   else:
       win.setProperty('wifi_device', '0')
       if bDebug: xbmcgui.Dialog().ok("connmanctl", 'set wifi indicator false')

   if bWifiTether:
       win.setProperty('tether_wifi', '1')
       if bDebug: xbmcgui.Dialog().ok("connmanctl", 'set tether indicator true')
   else:
       win.setProperty('tether_wifi', '0')
       if bDebug: xbmcgui.Dialog().ok("connmanctl", 'set tether indicator false')


def wifi_toggle():
   # xbmcgui.Dialog().ok("WiFi", "toggeling")
   busybox = xbmcgui.WindowXMLDialog('DialogBusy.xml', xbmcaddon.Addon(xbmc.getSkinDir()).getAddonInfo('path').decode('utf-8'), 'default', '720p')
   busybox.show()

   global bWifi
   global bWifiConnected
   wifi_state()

   if bWifi:
       f = os.popen("connmanctl disable wifi")
       xbmc.sleep(500)
       wifi_state()
   else:
       f = os.popen('connmanctl enable wifi')
       iBusyCnt = 60
       while not (bWifiConnected or bWifiTether):
           iBusyCnt = iBusyCnt - 1
           wifi_state()
           xbmc.sleep(300)
           if iBusyCnt < 0: break
       if not bWifiConnected and not bWifiTether: xbmcgui.Dialog().ok("WiFi Connection", "Not able to connect the Wifi Network")
   busybox.close()
   del busybox


def wifi_tether_toggle():
   # xbmcgui.Dialog().ok("WiFi Tethering", "toggeling")    
   global bWifiTether
   wifi_state()

   if bWifiTether:
       f = os.popen("sudo connmanctl tether wifi off")
       # xbmcgui.Dialog().ok("unknown arguments given", "wuerde jetzt deaktiv setzen")
       xbmc.sleep(300)
       wifi_state()
   else:
       # get values from skin
       wifitetherssid = xbmc.getInfoLabel('Skin.String(wifitetherssid)')
       wifitetherpw = xbmc.getInfoLabel('Skin.String(wifitetherpw)')
       # xbmcgui.Dialog().ok("unknown arguments given", "wuerde jetzt aktiv setzen")
       f = os.popen('connmanctl enable wifi')
       xbmc.sleep(1000)
       f = os.popen('sudo connmanctl tether wifi on \"' + wifitetherssid + '\" \"' + wifitetherpw + '\"')
       xbmc.sleep(300)
       wifi_state()
       if bWifiTether: xbmcgui.Dialog().ok('WiFi Hotspot ready for Connection', 'Name: ' + wifitetherssid, 'Password: ' + wifitetherpw)


def wifi_tether_ssid():
   global bWifiTether
   wifi_state()

   if bWifiTether:
       xbmcgui.Dialog().ok("Set HotSpot SSID", "Disable Hotspot before")
       quit()

   # get values from skin
   kb = xbmc.Keyboard('default', 'heading', True)
   kb.setDefault(xbmc.getInfoLabel('Skin.String(wifitetherssid)'))  # optional
   kb.setHeading('Enter Hotspot SSID')  # optional
   kb.setHiddenInput(False)  # optional
   kb.doModal()
   if (kb.isConfirmed()):
       wifitetherssid = kb.getText()
       print wifitetherssid
   else:
       quit()

   wifitetherpw = xbmc.getInfoLabel('Skin.String(wifitetherpw)')

   # xbmcgui.Dialog().ok("unknown arguments given", "wuerde jetzt aktiv setzen")

   f = os.popen('sudo connmanctl tether wifi \"' + wifitetherssid + '\" \"' + wifitetherpw + '\"')

   xbmc.sleep(300)
   wifi_state()


def wifi_tether_pw():
   global bWifiTether
   wifi_state()

   if bWifiTether:
       xbmcgui.Dialog().ok("Set HotSpot Password", "Disable Hotspot before")
       quit()

   # get values from skin
   wifitetherssid = xbmc.getInfoLabel('Skin.String(wifitetherssid)')

   kb = xbmc.Keyboard('default', 'heading', True)
   kb.setDefault(xbmc.getInfoLabel('Skin.String(wifitetherpw)'))  # optional
   kb.setHeading('Enter Hotspot Password')  # optional
   kb.setHiddenInput(False)  # optional
   kb.doModal()
   if (kb.isConfirmed()):
       wifitetherpw = kb.getText()
       print wifitetherpw
   else:
       quit()

   # xbmcgui.Dialog().ok("unknown arguments given", "wuerde jetzt aktiv setzen")

   f = os.popen('sudo connmanctl tether wifi \"' + wifitetherssid + '\" \"' + wifitetherpw + '\"')

   xbmc.sleep(300)
   wifi_state()


# programmcode

count = len(sys.argv) - 1

if count < 1:
   xbmcgui.Dialog().ok("No arguments given", "You must specify arguments to the script", "i.e. 'tether_toggle' - to toggle wifi tethering, etc")
else:
   if (sys.argv[1] == "state"):
       if bDebug: xbmcgui.Dialog().ok("WiFi", "only state")
       wifi_state()
   elif (sys.argv[1] == "wifi_toggle"):
       if bDebug: xbmcgui.Dialog().ok("WiFi", "toggle wifi")
       wifi_toggle()
   elif (sys.argv[1] == "tether_toggle"):
       if bDebug: xbmcgui.Dialog().ok("WiFi", "toggle tether")
       wifi_tether_toggle()
   elif (sys.argv[1] == "tether_ssid"):
       if bDebug: xbmcgui.Dialog().ok("WiFi", "set ssid")
       wifi_tether_ssid()
   elif (sys.argv[1] == "tether_pw"):
       if bDebug: xbmcgui.Dialog().ok("WiFi", "set pw")
       wifi_tether_pw()
   else:
       xbmcgui.Dialog().ok("unknown arguments given", sys.argv[1])

# xbmcgui.Dialog().ok("Code Ende", "test")
# xbmc.sleep(500)
# progress.close()
Zitieren


Nachrichten in diesem Thema
WifiManager - von hawkeyexp - 19.09.2016, 17:06
RE: Addon: WifiManager - Tester gesucht - von harryberlin - 19.09.2016, 17:57
RE: Addon: WifiManager 0.1.3 - von harryberlin - 02.10.2016, 09:30
RE: Addon: WifiManager 0.1.3 - von hawkeyexp - 02.10.2016, 15:39
RE: Addon: WifiManager 0.1.3 - von Jack - 02.10.2016, 17:34
RE: Addon: WifiManager 0.1.3 - von harryberlin - 02.10.2016, 21:27
RE: Addon: WifiManager 0.1.4 - von Jack - 02.10.2016, 23:01
RE: Addon: WifiManager 0.1.4 - von harryberlin - 02.10.2016, 23:17
RE: Addon: WifiManager 0.1.4 - von Jack - 02.10.2016, 23:29
RE: Addon: WifiManager 0.1.4 - von harryberlin - 03.10.2016, 00:46
RE: Addon: WifiManager 0.1.4 - von hawkeyexp - 03.10.2016, 01:08
RE: Addon: WifiManager 0.1.4 - von harryberlin - 03.10.2016, 01:17
RE: Addon: WifiManager 0.1.4 - von cbrauweiler - 03.10.2016, 09:43
RE: WifiManager 0.1.9 - von Merschi - 15.01.2017, 20:28
RE: WifiManager 0.1.9 - von Quoti30 - 26.01.2017, 13:40
RE: WifiManager 0.1.9 - von Skorpionbird - 26.01.2017, 13:47
RE: WifiManager 0.1.9 - von Quoti30 - 26.01.2017, 13:52
RE: WifiManager 0.1.9 - von cbrauweiler - 26.01.2017, 14:08
RE: WifiManager 0.1.9 - von hawkeyexp - 30.01.2017, 18:54
RE: WifiManager 0.1.9 - von Skorpionbird - 31.01.2017, 13:07
RE: WifiManager 0.1.9 - von cbrauweiler - 13.06.2017, 21:17
RE: WifiManager 0.1.9 - von Skorpionbird - 15.06.2017, 05:43
RE: WifiManager 0.1.9 - von cbrauweiler - 15.06.2017, 23:01
RE: WifiManager 0.1.9 - von hawkeyexp - 18.06.2017, 16:48
RE: WifiManager 0.1.9 - von Skorpionbird - 16.06.2017, 08:54
RE: WifiManager 0.1.9 - von cbrauweiler - 18.06.2017, 17:25
RE: WifiManager 0.1.9 - von harryberlin - 20.06.2017, 17:51
RE: WifiManager 0.1.9 - von hawkeyexp - 25.06.2017, 17:04
RE: WifiManager 0.1.9 - von hawkeyexp - 26.06.2017, 00:19
RE: WifiManager 0.1.9 - von harryberlin - 26.06.2017, 17:27
RE: WifiManager 0.1.9 - von Astraracer87 - 18.01.2018, 17:37
RE: WifiManager - von cbrauweiler - 19.01.2018, 11:09
RE: WifiManager - von harryberlin - 19.01.2018, 23:26
RE: WifiManager - von Astraracer87 - 09.02.2018, 13:30
RE: WifiManager - von frank.sass@online.de - 04.05.2021, 19:20

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 9 Gast/Gäste
RasPiCarProjekt