auto discovery working, still need to tweak manual input, connecting to db works after discover is done
This commit is contained in:
parent
5fbcc143bc
commit
6a26761cc7
41
launch.py
41
launch.py
|
@ -1,39 +1,16 @@
|
|||
import mc
|
||||
import sys
|
||||
|
||||
|
||||
#import mythboxee
|
||||
|
||||
import signal
|
||||
import mythtv
|
||||
import mythboxee
|
||||
|
||||
# Get Access to the Apps Local Config
|
||||
#config = mc.GetApp().GetLocalConfig()
|
||||
# DEBUG #
|
||||
#mc.GetApp().GetLocalConfig().SetValue("dbconn", "")
|
||||
# DEBUG #
|
||||
|
||||
# For Debugging
|
||||
#config.SetValue("verified", "")
|
||||
#config.SetValue("server", "")
|
||||
# Activate Loading Window
|
||||
mc.ActivateWindow(14001)
|
||||
|
||||
mc.ActivateWindow(14005)
|
||||
# Lets go ahead and launch the app
|
||||
mythboxee.Launch()
|
||||
|
||||
db = mythtv.MythDB(SecurityPin=4365)
|
||||
|
||||
be = mythtv.MythBE(db=db)
|
||||
print be.getRecordings()
|
||||
|
||||
# Pull out some of the variables we need
|
||||
#server = config.GetValue("server")
|
||||
#verified = config.GetValue("verified")
|
||||
|
||||
# If the server hasn't been defined, we need to get it.
|
||||
#if not server:
|
||||
# mythboxee.GetServer()
|
||||
|
||||
# If server is set, and at this point it has been verified
|
||||
# then launch the application
|
||||
#if config.GetValue("verified") == "1":
|
||||
# mc.ActivateWindow(14000)
|
||||
|
||||
# Load all the show data from the MythTV Backend Server
|
||||
# mythboxee.LoadShows()
|
||||
#else:
|
||||
# mc.ShowDialogOk("MythBoxee Error", "You must enter the full path to the MythBoxee script or MythBoxee was unable to verify the URL provided.")
|
58
mythboxee.py
58
mythboxee.py
|
@ -1,13 +1,71 @@
|
|||
import mc
|
||||
import re
|
||||
import mythtv
|
||||
from mythtv import MythError
|
||||
from operator import itemgetter, attrgetter
|
||||
|
||||
mbbe = None
|
||||
mbdb = None
|
||||
|
||||
config = mc.GetApp().GetLocalConfig()
|
||||
|
||||
titles = []
|
||||
recordings = []
|
||||
idbanners = {}
|
||||
shows = {}
|
||||
|
||||
|
||||
def DiscoverBackend():
|
||||
mc.ShowDialogNotification("DiscoverBackend")
|
||||
|
||||
pin = config.GetValue("pin")
|
||||
dbconn = config.GetValue("dbconn")
|
||||
|
||||
if not pin:
|
||||
pin = 0000
|
||||
|
||||
try:
|
||||
db = mythtv.MythDB(SecurityPin=pin)
|
||||
except Exception, e:
|
||||
mc.ShowDialogNotification(e.message)
|
||||
if e.ename == 'DB_CREDENTIALS' and count < 3:
|
||||
mc.ActivateWindow(14002)
|
||||
mc.GetWindow(14002).GetControl(6020).SetVisible(False)
|
||||
mc.GetWindow(14002).GetControl(6010).SetVisible(True)
|
||||
mc.GetWindow(14002).GetControl(6011).SetFocus()
|
||||
elif e.ename == 'DB_CONNECTION' or e.ename == 'DB_CREDENTIALS' and count > 3:
|
||||
mc.ActivateWindow(14002)
|
||||
mc.GetWindow(14002).GetControl(6010).SetVisible(False)
|
||||
mc.GetWindow(14002).GetControl(6020).SetVisible(True)
|
||||
mc.GetWindow(14002).GetControl(6021).SetFocus()
|
||||
return False
|
||||
else:
|
||||
mc.ShowDialogNotification(str(db.dbconn))
|
||||
config.SetValue("dbconn", str(db.dbconn))
|
||||
return True
|
||||
|
||||
|
||||
def Launch():
|
||||
# If dbconn isn't set, we'll assume we haven't found the backend.
|
||||
if not config.GetValue("dbconn"):
|
||||
discoverBackend = False
|
||||
while discoverBackend is False:
|
||||
discoverBackend = DiscoverBackend()
|
||||
|
||||
# Parse our DB info
|
||||
dbconn = config.GetValue("dbconn")
|
||||
dbconf = eval(dbconn)
|
||||
|
||||
# Now that the backend has been discovered, lets connect.
|
||||
try:
|
||||
mbdb = mythtv.MythDB(**dbconf)
|
||||
except MythError, e:
|
||||
print e.message
|
||||
mc.ShowDialogNotification("Failed to connect to the MythTV Backend")
|
||||
else:
|
||||
mbbe = mythtv.MythBE(db=mbdb)
|
||||
mc.ActivateWindow(14010)
|
||||
|
||||
|
||||
def LoadShows():
|
||||
del titles[:]
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
import mc
|
||||
|
||||
def CreateConnection():
|
||||
try:
|
||||
pin = mc.GetApp().GetLocalConfig().GetValue("pin")
|
||||
if not pin:
|
||||
pin = 0000
|
||||
db = mythtv.MythDB(SecurityPin=pin)
|
||||
except Exception, e:
|
||||
if e.ename == 'DB_CREDENTIALS':
|
||||
mc.ShowDialogNotification("Unable to connect, try to manually set the security pin.")
|
||||
mc.ActivateWindow(14006)
|
||||
mc.GetWindow(14006).GetControl(6010).SetVisible(True)
|
||||
mc.GetWindow(14006).GetControl(6020).SetVisible(False)
|
||||
mc.GetWindow(14006).GetControl(6011).SetFocus()
|
||||
elif e.ename == 'DB_CONNECTION':
|
||||
mc.ActivateWindow(14006)
|
||||
mc.GetWindow(14006).GetControl(6010).SetVisible(False)
|
||||
mc.GetWindow(14006).GetControl(6020).SetVisible(True)
|
||||
mc.GetWindow(14006).GetControl(6021).SetFocus()
|
||||
|
|
@ -796,7 +796,7 @@ class MythDBConn( object ):
|
|||
self.db = mysql.connector.connect(user=dbconn['DBUserName'],
|
||||
host=dbconn['DBHostName'],
|
||||
password=dbconn['DBPassword'],
|
||||
database=dbconn['DBName'],
|
||||
db=dbconn['DBName'],
|
||||
port=dbconn['DBPort'],
|
||||
use_unicode=True,
|
||||
charset='utf8')
|
||||
|
@ -1000,7 +1000,6 @@ class MythDBBase( object ):
|
|||
else:
|
||||
# fall back to UPnP
|
||||
dbconn = self._listenUPNP(dbconn['SecurityPin'], 5.0)
|
||||
|
||||
# push data to new settings file
|
||||
settings = [dbconn[key] for key in \
|
||||
('SecurityPin','DBHostName','DBUserName',
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0"?>
|
||||
<window type="window" id="14001">
|
||||
<defaultcontrol always="true">9001</defaultcontrol>
|
||||
<allowoverlay>yes</allowoverlay>
|
||||
<controls>
|
||||
<control type="image" id="1001">
|
||||
<width>1280</width>
|
||||
<height>720</height>
|
||||
<texture>mb_bg_setup.png</texture>
|
||||
<animation effect="fade" start="85" end="85" time="0" condition="true">Conditional</animation>
|
||||
</control>
|
||||
<control type="image" id="1002">
|
||||
<description>logo</description>
|
||||
<posx>450</posx>
|
||||
<posy>250</posy>
|
||||
<width>402</width>
|
||||
<height>107</height>
|
||||
<texture flipY="true" flipX="false">logo.png</texture>
|
||||
<aspectratio>keep</aspectratio>
|
||||
</control>
|
||||
</controls>
|
||||
</window>
|
|
@ -1,12 +1,18 @@
|
|||
<?xml version="1.0"?>
|
||||
<window type="window" id="14000">
|
||||
<window type="window" id="14010">
|
||||
<defaultcontrol always="true">13</defaultcontrol>
|
||||
<allowoverlay>yes</allowoverlay>
|
||||
<onload lang="python"><![CDATA[
|
||||
import mythboxee
|
||||
|
||||
]]></onload>
|
||||
<onunload lang="python">
|
||||
<![CDATA[
|
||||
mc.ActivateWindow(10482)
|
||||
]]>
|
||||
</onunload>
|
||||
<controls>
|
||||
<control type="visualisation" id ="5001">
|
||||
<control type="visualisation" id ="2001">
|
||||
<width>1280</width>
|
||||
<height>720</height>
|
||||
<visible>Control.IsVisible(2000)</visible>
|
||||
|
@ -17,7 +23,7 @@ import mythboxee
|
|||
<texture>mb_bg.png</texture>
|
||||
<animation effect="fade" start="85" end="85" time="0" condition="true">Conditional</animation>
|
||||
</control>
|
||||
<control type="grouplist" id="1000">
|
||||
<control type="grouplist" id="2002">
|
||||
<posy>11</posy>
|
||||
<posx>216</posx>
|
||||
<itemgap>20</itemgap>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<window type="window" id="14005">
|
||||
<defaultcontrol always="true">9001</defaultcontrol>
|
||||
<window type="window" id="14002">
|
||||
<defaultcontrol always="true">6003</defaultcontrol>
|
||||
<allowoverlay>yes</allowoverlay>
|
||||
<controls>
|
||||
<control type="visualisation" id ="5001">
|
||||
|
@ -21,30 +21,181 @@
|
|||
<ondown>2000</ondown>
|
||||
<orientation>horizontal</orientation>
|
||||
</control>
|
||||
<control type="image" id="5001">
|
||||
<control type="image" id="5002">
|
||||
<description>logo</description>
|
||||
<posx>450</posx>
|
||||
<posy>250</posy>
|
||||
<posy>150</posy>
|
||||
<width>402</width>
|
||||
<height>107</height>
|
||||
<texture flipY="true" flipX="false">logo.png</texture>
|
||||
<aspectratio>keep</aspectratio>
|
||||
</control>
|
||||
<control type="label" id="5002">
|
||||
<description>some label that shows text</description>
|
||||
<posx>425</posx>
|
||||
<posy>580</posy>
|
||||
<width>450</width>
|
||||
<height>40</height>
|
||||
<align>center</align>
|
||||
<aligny>center</aligny>
|
||||
<scroll>false</scroll>
|
||||
<label>Attempting to Locate MythTV Backend</label>
|
||||
<number></number>
|
||||
<haspath>false</haspath>
|
||||
<font>font18</font>
|
||||
<textcolor>white</textcolor>
|
||||
<wrapmultiline>false</wrapmultiline>
|
||||
<control type="group" id="6010">
|
||||
<control type="edit" id="6011">
|
||||
<posx>515</posx>
|
||||
<posy>300</posy>
|
||||
<width>275</width>
|
||||
<height>46</height>
|
||||
<label>Security Pin:</label>
|
||||
<textoffsetx>8</textoffsetx>
|
||||
<ondown>6012</ondown>
|
||||
<align>right</align>
|
||||
<aligny>right</aligny>
|
||||
<font>font28</font>
|
||||
<textcolor>white</textcolor>
|
||||
</control>
|
||||
<control type="button" id="6012">
|
||||
<description>login button control</description>
|
||||
<posx>415</posx>
|
||||
<posy>370</posy>
|
||||
<width>200</width>
|
||||
<height>40</height>
|
||||
<visible>true</visible>
|
||||
<colordiffuse>FFFFFFFF</colordiffuse>
|
||||
<label>Connect</label>
|
||||
<font>font21</font>
|
||||
<textcolor>white</textcolor>
|
||||
<disabledcolor>88FFFFFF</disabledcolor>
|
||||
<align>center</align>
|
||||
<aligny>center</aligny>
|
||||
<textoffsetx>20</textoffsetx>
|
||||
<textoffsety>-</textoffsety>
|
||||
<onfocus>-</onfocus>
|
||||
<onup>6011</onup>
|
||||
<onright>6013</onright>
|
||||
<onclick lang="python">
|
||||
<![CDATA[
|
||||
pin = mc.GetWindow(14006).GetEdit(6011).GetText()
|
||||
mc.GetApp().GetLocalConfig().SetValue("pin", pin)
|
||||
mc.ShowDialogNotification(pin)
|
||||
mc.ActivateWindow(14005)
|
||||
]]>
|
||||
</onclick>
|
||||
</control>
|
||||
<control type="button" id="6013">
|
||||
<description>login button control</description>
|
||||
<posx>685</posx>
|
||||
<posy>370</posy>
|
||||
<width>200</width>
|
||||
<height>40</height>
|
||||
<visible>true</visible>
|
||||
<colordiffuse>FFFFFFFF</colordiffuse>
|
||||
<label>Exit</label>
|
||||
<font>font21</font>
|
||||
<textcolor>white</textcolor>
|
||||
<disabledcolor>88FFFFFF</disabledcolor>
|
||||
<align>center</align>
|
||||
<aligny>center</aligny>
|
||||
<textoffsetx>20</textoffsetx>
|
||||
<textoffsety>-</textoffsety>
|
||||
<onfocus>-</onfocus>
|
||||
<onup>6011</onup>
|
||||
<onleft>6012</onleft>
|
||||
<onclick lang="python"><![CDATA[
|
||||
mc.CloseWindow()
|
||||
]]></onclick>
|
||||
</control>
|
||||
</control>
|
||||
<control type="group" id="6020">
|
||||
<control type="edit" id="6021">
|
||||
<posx>515</posx>
|
||||
<posy>300</posy>
|
||||
<width>275</width>
|
||||
<height>46</height>
|
||||
<label>Hostname:</label>
|
||||
<textoffsetx>8</textoffsetx>
|
||||
<ondown>6012</ondown>
|
||||
<align>right</align>
|
||||
<aligny>right</aligny>
|
||||
<font>font28</font>
|
||||
<textcolor>white</textcolor>
|
||||
</control>
|
||||
<control type="edit" id="6022">
|
||||
<posx>515</posx>
|
||||
<posy>320</posy>
|
||||
<width>275</width>
|
||||
<height>46</height>
|
||||
<label>Username:</label>
|
||||
<textoffsetx>8</textoffsetx>
|
||||
<ondown>6012</ondown>
|
||||
<align>right</align>
|
||||
<aligny>right</aligny>
|
||||
<font>font28</font>
|
||||
<textcolor>white</textcolor>
|
||||
</control>
|
||||
<control type="edit" id="6023">
|
||||
<posx>515</posx>
|
||||
<posy>340</posy>
|
||||
<width>275</width>
|
||||
<height>46</height>
|
||||
<label>Password:</label>
|
||||
<textoffsetx>8</textoffsetx>
|
||||
<ondown>6012</ondown>
|
||||
<align>right</align>
|
||||
<aligny>right</aligny>
|
||||
<font>font28</font>
|
||||
<textcolor>white</textcolor>
|
||||
</control>
|
||||
<control type="edit" id="6024">
|
||||
<posx>515</posx>
|
||||
<posy>360</posy>
|
||||
<width>275</width>
|
||||
<height>46</height>
|
||||
<label>Database:</label>
|
||||
<textoffsetx>8</textoffsetx>
|
||||
<ondown>6012</ondown>
|
||||
<align>right</align>
|
||||
<aligny>right</aligny>
|
||||
<font>font28</font>
|
||||
<textcolor>white</textcolor>
|
||||
</control>
|
||||
<control type="button" id="6025">
|
||||
<description>login button control</description>
|
||||
<posx>555</posx>
|
||||
<posy>370</posy>
|
||||
<width>200</width>
|
||||
<height>40</height>
|
||||
<visible>true</visible>
|
||||
<colordiffuse>FFFFFFFF</colordiffuse>
|
||||
<label>Connect</label>
|
||||
<font>font21</font>
|
||||
<textcolor>white</textcolor>
|
||||
<disabledcolor>88FFFFFF</disabledcolor>
|
||||
<align>center</align>
|
||||
<aligny>center</aligny>
|
||||
<textoffsetx>20</textoffsetx>
|
||||
<textoffsety>-</textoffsety>
|
||||
<onfocus>-</onfocus>
|
||||
<onup>6024</onup>
|
||||
<onright>6026</onright>
|
||||
<onclick lang="python"><![CDATA[
|
||||
pin = mc.GetWindow(14006).GetEdit(6003).GetText()
|
||||
mc.GetApp().GetLocalConfig().SetValue("pin", pin)
|
||||
]]></onclick>
|
||||
</control>
|
||||
<control type="button" id="6026">
|
||||
<description>login button control</description>
|
||||
<posx>555</posx>
|
||||
<posy>370</posy>
|
||||
<width>200</width>
|
||||
<height>40</height>
|
||||
<visible>true</visible>
|
||||
<colordiffuse>FFFFFFFF</colordiffuse>
|
||||
<label>Exit</label>
|
||||
<font>font21</font>
|
||||
<textcolor>white</textcolor>
|
||||
<disabledcolor>88FFFFFF</disabledcolor>
|
||||
<align>center</align>
|
||||
<aligny>center</aligny>
|
||||
<textoffsetx>20</textoffsetx>
|
||||
<textoffsety>-</textoffsety>
|
||||
<onfocus>-</onfocus>
|
||||
<onup>6024</onup>
|
||||
<onleft>6025</onleft>
|
||||
<onclick lang="python"><![CDATA[
|
||||
mc.CloseWindow()
|
||||
]]></onclick>
|
||||
</control>
|
||||
</control>
|
||||
</controls>
|
||||
</window>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<window type="window" id="14001">
|
||||
<window type="window" id="14011">
|
||||
<defaultcontrol always="true">2013</defaultcontrol>
|
||||
<allowoverlay>no</allowoverlay>
|
||||
<onload lang="python"><![CDATA[
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 350 B |
Binary file not shown.
After Width: | Height: | Size: 363 B |
Loading…
Reference in New Issue