From 94e829c73082dcd8e6f04d34cf6e94d4435f0dda Mon Sep 17 00:00:00 2001 From: unfledged Date: Sat, 5 Sep 2015 00:02:02 +0100 Subject: [PATCH 1/2] Remove references to Kodi v13 Makes minimal version for script v14 - previous Kodi versions will be missing available shortcuts, both in available shortcuts and built menus. Assuming minimum version for repo push is now v14. --- addon.xml | 2 +- default.py | 2 +- resources/lib/datafunctions.py | 2 +- resources/lib/gui.py | 2 +- resources/lib/library.py | 58 +++++++++------------------ resources/lib/nodefunctions.py | 2 +- resources/lib/template.py | 2 +- resources/lib/xmlfunctions.py | 2 +- resources/shortcuts/livetv.DATA.xml | 32 --------------- resources/shortcuts/mainmenu.DATA.xml | 10 ----- resources/shortcuts/overrides.xml | 18 +-------- 11 files changed, 27 insertions(+), 105 deletions(-) diff --git a/addon.xml b/addon.xml index 77b3bd73..8c1a3da6 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ - + diff --git a/default.py b/default.py index 63123e9e..98473679 100644 --- a/default.py +++ b/default.py @@ -40,7 +40,7 @@ hashlist = [] def log(txt): - if __xbmcversion__ == "13" or __addon__.getSetting( "enable_logging" ) == "true": + if __addon__.getSetting( "enable_logging" ) == "true": if isinstance (txt,str): txt = txt.decode('utf-8') message = u'%s: %s' % (__addonid__, txt) diff --git a/resources/lib/datafunctions.py b/resources/lib/datafunctions.py index 60f927b4..e34b5fee 100644 --- a/resources/lib/datafunctions.py +++ b/resources/lib/datafunctions.py @@ -40,7 +40,7 @@ REMOVE_REXP = re.compile('-{2,}') def log(txt): - if __xbmcversion__ == "13" or __addon__.getSetting( "enable_logging" ) == "true": + if __addon__.getSetting( "enable_logging" ) == "true": try: if isinstance (txt,str): txt = txt.decode('utf-8') diff --git a/resources/lib/gui.py b/resources/lib/gui.py index 812e3f7b..5008ce70 100644 --- a/resources/lib/gui.py +++ b/resources/lib/gui.py @@ -37,7 +37,7 @@ xbmcvfs.mkdir(__datapath__) def log(txt): - if __xbmcversion__ == "13" or __addon__.getSetting( "enable_logging" ) == "true": + if __addon__.getSetting( "enable_logging" ) == "true": try: if isinstance (txt,str): txt = txt.decode('utf-8') diff --git a/resources/lib/library.py b/resources/lib/library.py index 17b936ac..b86fd4e3 100755 --- a/resources/lib/library.py +++ b/resources/lib/library.py @@ -30,7 +30,7 @@ __xbmcversion__ = xbmc.getInfoLabel( "System.BuildVersion" ).split(".")[0] def log(txt): - if __xbmcversion__ == "13" or __addon__.getSetting( "enable_logging" ) == "true": + if __addon__.getSetting( "enable_logging" ) == "true": try: if isinstance (txt,str): txt = txt.decode('utf-8') @@ -739,12 +739,9 @@ def common( self ): listitems.append( self._create(["ActivateWindow(Videos,videodb://movies/titles/,return)", "342", "32034", {"icon": "DefaultMovies.png"} ]) ) listitems.append( self._create(["ActivateWindow(Videos,videodb://tvshows/titles/,return)", "20343", "32034", {"icon": "DefaultTVShows.png"} ]) ) - if __xbmcversion__ == "13": - listitems.append( self._create(["ActivateWindowAndFocus(MyPVR,34,0 ,13,0)", "32022", "32034", {"icon": "DefaultTVShows.png"} ]) ) - else: - listitems.append( self._create(["ActivateWindow(TVGuide)", "32022", "32034", {"icon": "DefaultTVShows.png"} ]) ) - listitems.append( self._create(["ActivateWindow(RadioGuide)", "32087", "32034", {"icon": "DefaultTVShows.png"} ]) ) - + listitems.append( self._create(["ActivateWindow(TVGuide)", "32022", "32034", {"icon": "DefaultTVShows.png"} ]) ) + listitems.append( self._create(["ActivateWindow(RadioGuide)", "32087", "32034", {"icon": "DefaultTVShows.png"} ]) ) + listitems.append( self._create(["ActivateWindow(Music)", "10005", "32034", {"icon": "DefaultMusicAlbums.png"} ]) ) listitems.append( self._create(["ActivateWindow(Videos,videodb://musicvideos/titles/,return)", "20389", "32034", {"icon": "DefaultMusicVideos.png"} ] ) ) listitems.append( self._create(["ActivateWindow(Pictures)", "10002", "32034", {"icon": "DefaultPicture.png"} ] ) ) @@ -800,20 +797,12 @@ def more( self ): listitems.append( self._create(["Mastermode", "20045", "32054", {} ]) ) listitems.append( self._create(["RipCD", "600", "32054", {} ]) ) - - if __xbmcversion__ == "13": - listitems.append( self._create(["UpdateLibrary(video)", "32046", "32054", {} ]) ) - listitems.append( self._create(["UpdateLibrary(music)", "32047", "32054", {} ]) ) - else: - listitems.append( self._create(["UpdateLibrary(video,,true)", "32046", "32054", {} ]) ) - listitems.append( self._create(["UpdateLibrary(music,,true)", "32047", "32054", {} ]) ) - - if __xbmcversion__ == "13": - listitems.append( self._create(["CleanLibrary(video)", "32055", "32054", {} ]) ) - listitems.append( self._create(["CleanLibrary(music)", "32056", "32054", {} ]) ) - else: - listitems.append( self._create(["CleanLibrary(video,true)", "32055", "32054", {} ]) ) - listitems.append( self._create(["CleanLibrary(music,true)", "32056", "32054", {} ]) ) + + listitems.append( self._create(["UpdateLibrary(video,,true)", "32046", "32054", {} ]) ) + listitems.append( self._create(["UpdateLibrary(music,,true)", "32047", "32054", {} ]) ) + + listitems.append( self._create(["CleanLibrary(video,true)", "32055", "32054", {} ]) ) + listitems.append( self._create(["CleanLibrary(music,true)", "32056", "32054", {} ]) ) self.addToDictionary( "commands", listitems ) @@ -875,25 +864,14 @@ def pvrlibrary( self ): log('Listing pvr library...') # PVR - if __xbmcversion__ == "13": - listitems.append( self._create(["ActivateWindowAndFocus(MyPVR,32,0 ,11,0)", "19023", "32017", {"icon": "DefaultTVShows.png"} ] ) ) - listitems.append( self._create(["ActivateWindowAndFocus(MyPVR,33,0 ,12,0)", "19024", "32017", {"icon": "DefaultTVShows.png"} ] ) ) - listitems.append( self._create(["ActivateWindowAndFocus(MyPVR,31,0 ,10,0)", "19069", "32017", {"icon": "DefaultTVShows.png"} ] ) ) - listitems.append( self._create(["ActivateWindowAndFocus(MyPVR,34,0 ,13,0)", "19163", "32017", {"icon": "DefaultTVShows.png"} ] ) ) - listitems.append( self._create(["ActivateWindowAndFocus(MyPVR,35,0 ,14,0)", "32023", "32017", {"icon": "DefaultTVShows.png"} ] ) ) - - listitems.append( self._create(["PlayPvrTV", "32066", "32017", {"icon": "DefaultTVShows.png"} ] ) ) - listitems.append( self._create(["PlayPvrRadio", "32067", "32017", {"icon": "DefaultTVShows.png"} ] ) ) - listitems.append( self._create(["PlayPvr", "32068", "32017", {"icon": "DefaultTVShows.png"} ] ) ) - else: - listitems.append( self._create(["ActivateWindow(TVChannels)", "19019", "32017", {"icon": "DefaultTVShows.png"} ] ) ) - listitems.append( self._create(["ActivateWindow(TVGuide)", "22020", "32017", {"icon": "DefaultTVShows.png"} ] ) ) - listitems.append( self._create(["ActivateWindow(TVRecordings)", "19163", "32017", {"icon": "DefaultTVShows.png"} ] ) ) - listitems.append( self._create(["ActivateWindow(TVTimers)", "19040", "32017", {"icon": "DefaultTVShows.png"} ] ) ) - listitems.append( self._create(["ActivateWindow(TVSearch)", "137", "32017", {"icon": "DefaultTVShows.png"} ] ) ) - - listitems.append( self._create(["PlayPvrTV", "32066", "32017", {"icon": "DefaultTVShows.png"} ] ) ) - listitems.append( self._create(["PlayPvr", "32068", "32017", {"icon": "DefaultTVShows.png"} ] ) ) + listitems.append( self._create(["ActivateWindow(TVChannels)", "19019", "32017", {"icon": "DefaultTVShows.png"} ] ) ) + listitems.append( self._create(["ActivateWindow(TVGuide)", "22020", "32017", {"icon": "DefaultTVShows.png"} ] ) ) + listitems.append( self._create(["ActivateWindow(TVRecordings)", "19163", "32017", {"icon": "DefaultTVShows.png"} ] ) ) + listitems.append( self._create(["ActivateWindow(TVTimers)", "19040", "32017", {"icon": "DefaultTVShows.png"} ] ) ) + listitems.append( self._create(["ActivateWindow(TVSearch)", "137", "32017", {"icon": "DefaultTVShows.png"} ] ) ) + + listitems.append( self._create(["PlayPvrTV", "32066", "32017", {"icon": "DefaultTVShows.png"} ] ) ) + listitems.append( self._create(["PlayPvr", "32068", "32017", {"icon": "DefaultTVShows.png"} ] ) ) self.addToDictionary( "pvr", listitems ) diff --git a/resources/lib/nodefunctions.py b/resources/lib/nodefunctions.py index af26767d..7bc04e05 100755 --- a/resources/lib/nodefunctions.py +++ b/resources/lib/nodefunctions.py @@ -41,7 +41,7 @@ REMOVE_REXP = re.compile('-{2,}') def log(txt): - if __xbmcversion__ == "13" or __addon__.getSetting( "enable_logging" ) == "true": + if __addon__.getSetting( "enable_logging" ) == "true": try: if isinstance (txt,str): txt = txt.decode('utf-8') diff --git a/resources/lib/template.py b/resources/lib/template.py index 21adfb3c..7599643c 100755 --- a/resources/lib/template.py +++ b/resources/lib/template.py @@ -12,7 +12,7 @@ __skinpath__ = xbmc.translatePath( "special://skin/shortcuts/" ).decode('utf-8') def log(txt): - if __xbmcversion__ == "13" or __addon__.getSetting( "enable_logging" ) == "true": + if __addon__.getSetting( "enable_logging" ) == "true": try: if isinstance (txt,str): txt = txt.decode('utf-8') diff --git a/resources/lib/xmlfunctions.py b/resources/lib/xmlfunctions.py index 80598ca3..5a98748f 100644 --- a/resources/lib/xmlfunctions.py +++ b/resources/lib/xmlfunctions.py @@ -27,7 +27,7 @@ import hashlib, hashlist def log(txt): - if __xbmcversion__ == "13" or __addon__.getSetting( "enable_logging" ) == "true": + if __addon__.getSetting( "enable_logging" ) == "true": if isinstance (txt,str): txt = txt.decode('utf-8') message = u'%s: %s' % (__addonid__, txt) diff --git a/resources/shortcuts/livetv.DATA.xml b/resources/shortcuts/livetv.DATA.xml index 00895620..957c4944 100644 --- a/resources/shortcuts/livetv.DATA.xml +++ b/resources/shortcuts/livetv.DATA.xml @@ -1,37 +1,5 @@ - - - 32017 - DefaultTVShows.png - - ActivateWindowAndFocus(MyPVR,32,0 ,11,0) - 13 - - - - 32017 - DefaultTVShows.png - - ActivateWindow(TVChannels) - 14 - - - - 32017 - DefaultTVShows.png - - ActivateWindowAndFocus(MyPVR,33,0 ,12,0) - 13 - - - - 32017 - DefaultTVShows.png - - ActivateWindowAndFocus(MyPVR,31,0 ,10,0) - 13 - 32017 diff --git a/resources/shortcuts/mainmenu.DATA.xml b/resources/shortcuts/mainmenu.DATA.xml index 48c670fd..edd54bf3 100644 --- a/resources/shortcuts/mainmenu.DATA.xml +++ b/resources/shortcuts/mainmenu.DATA.xml @@ -14,21 +14,12 @@ ActivateWindow(Pictures) - - - 32034 - DefaultTVShows.png - - ActivateWindowAndFocus(MyPVR,34,0 ,13,0) - 13 - 32034 DefaultTVShows.png ActivateWindow(TVGuide) - 14 @@ -36,7 +27,6 @@ DefaultAudio.png ActivateWindow(RadioGuide) - 14 diff --git a/resources/shortcuts/overrides.xml b/resources/shortcuts/overrides.xml index 863fdaca..0fbf1b26 100755 --- a/resources/shortcuts/overrides.xml +++ b/resources/shortcuts/overrides.xml @@ -28,15 +28,6 @@ All All - - 14 - 14 - 14 - - All - All - All - @@ -50,16 +41,11 @@ music - + pvr pvr-tv - pvr-radio - - pvr - pvr-tv - - + radio pvr-radio From ecddb17422942ce059adbc12798d0939d2047e59 Mon Sep 17 00:00:00 2001 From: unfledged Date: Sat, 5 Sep 2015 00:39:14 +0100 Subject: [PATCH 2/2] Enable debug logging on menu build failure, regardless of log-uploader script status --- resources/lib/xmlfunctions.py | 79 ++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/resources/lib/xmlfunctions.py b/resources/lib/xmlfunctions.py index 5a98748f..56401b9a 100644 --- a/resources/lib/xmlfunctions.py +++ b/resources/lib/xmlfunctions.py @@ -104,51 +104,54 @@ def buildMenu( self, mainmenuID, groups, numLevels, buildMode, options, weEnable # Menu is built, reload the skin xbmc.executebuiltin( "XBMC.ReloadSkin()" ) else: - # Menu couldn't be built - if the user has script.xbmc.debug.log offer to upload a debug log - if xbmc.getCondVisibility( "System.HasAddon( script.xbmc.debug.log )" ): - # If we enabled debug logging - if weEnabledSystemDebug or weEnabledScriptDebug: - # Disable any logging we enabled - if weEnabledSystemDebug: - json_query = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method":"Settings.setSettingValue", "params": {"setting":"debug.showloginfo", "value":false} } ' ) - if weEnabledScriptDebug: - __addon__.setSetting( "enable_logging", "false" ) - - # Offer to upload a debug log + # Menu couldn't be built - generate a debug log + + # If we enabled debug logging + if weEnabledSystemDebug or weEnabledScriptDebug: + # Disable any logging we enabled + if weEnabledSystemDebug: + json_query = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method":"Settings.setSettingValue", "params": {"setting":"debug.showloginfo", "value":false} } ' ) + if weEnabledScriptDebug: + __addon__.setSetting( "enable_logging", "false" ) + + # Offer to upload a debug log + if xbmc.getCondVisibility( "System.HasAddon( script.xbmc.debug.log )" ): ret = xbmcgui.Dialog().yesno( __addon__.getAddonInfo( "name" ), __language__( 32092 ), __language__( 32093 ) ) if ret: - xbmc.executebuiltin( "RunScript(script.xbmc.debug.log)" ) - + xbmc.executebuiltin( "RunScript(script.xbmc.debug.log)" ) else: - # Enable any debug logging needed - json_query = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method": "Settings.getSettings", "params": { "filter":{"section":"system", "category":"debug"} } }') - json_query = unicode(json_query, 'utf-8', errors='ignore') - json_response = simplejson.loads(json_query) + xbmcgui.Dialog().ok( __addon__.getAddonInfo( "name" ), __language__( 32092 ), __language__( 32094 ) ) - enabledSystemDebug = False - enabledScriptDebug = False - if json_response.has_key('result') and json_response['result'].has_key('settings') and json_response['result']['settings'] is not None: - for item in json_response['result']['settings']: - if item["id"] == "debug.showloginfo": - if item["value"] == False: - json_query = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method":"Settings.setSettingValue", "params": {"setting":"debug.showloginfo", "value":true} } ' ) - enabledSystemDebug = True + else: + # Enable any debug logging needed + json_query = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method": "Settings.getSettings", "params": { "filter":{"section":"system", "category":"debug"} } }') + json_query = unicode(json_query, 'utf-8', errors='ignore') + json_response = simplejson.loads(json_query) + + enabledSystemDebug = False + enabledScriptDebug = False + if json_response.has_key('result') and json_response['result'].has_key('settings') and json_response['result']['settings'] is not None: + for item in json_response['result']['settings']: + if item["id"] == "debug.showloginfo": + if item["value"] == False: + json_query = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method":"Settings.setSettingValue", "params": {"setting":"debug.showloginfo", "value":true} } ' ) + enabledSystemDebug = True + + if __addon__.getSetting( "enable_logging" ) != "true": + __addon__.setSetting( "enable_logging", "true" ) + enabledScriptDebug = True - if __addon__.getSetting( "enable_logging" ) != "true": - __addon__.setSetting( "enable_logging", "true" ) - enabledScriptDebug = True - - if enabledSystemDebug or enabledScriptDebug: - # We enabled one or more of the debug options, re-run this function - self.buildMenu( mainmenuID, groups, numLevels, buildMode, options, enabledSystemDebug, enabledScriptDebug ) - else: - # Debug logging already enabled - offer to upload a debug log + if enabledSystemDebug or enabledScriptDebug: + # We enabled one or more of the debug options, re-run this function + self.buildMenu( mainmenuID, groups, numLevels, buildMode, options, enabledSystemDebug, enabledScriptDebug ) + else: + # Offer to upload a debug log + if xbmc.getCondVisibility( "System.HasAddon( script.xbmc.debug.log )" ): ret = xbmcgui.Dialog().yesno( __addon__.getAddonInfo( "name" ), __language__( 32092 ), __language__( 32093 ) ) if ret: - xbmc.executebuiltin( "RunScript(script.xbmc.debug.log)" ) - - else: - xbmcgui.Dialog().ok( __addon__.getAddonInfo( "name" ), __language__( 32092 ), __language__( 32094 ) ) + xbmc.executebuiltin( "RunScript(script.xbmc.debug.log)" ) + else: + xbmcgui.Dialog().ok( __addon__.getAddonInfo( "name" ), __language__( 32092 ), __language__( 32094 ) ) def shouldwerun( self, profilelist ): try: