From fa8a54dd7b15b4baf85385646ca7fd7818c3973d Mon Sep 17 00:00:00 2001 From: persianpros Date: Mon, 10 May 2021 10:53:53 +0430 Subject: [PATCH 1/7] PEP8 double aggressive E701, E70 and E502 --- src/plugin/plugin.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugin/plugin.py b/src/plugin/plugin.py index bf86818..46dbfa8 100644 --- a/src/plugin/plugin.py +++ b/src/plugin/plugin.py @@ -57,7 +57,8 @@ def SaveDesktopInfo(): try: _g_dw = getDesktop(0).size().width() _g_dh = getDesktop(0).size().height() - except: _g_dw,_g_dh = 1280,720 + except: + _g_dw,_g_dh = 1280,720 print "[XBMC] Desktop size [%dx%d]" % (_g_dw,_g_dh) open("/tmp/dw.info", "w").write(str(_g_dw) + "x" + str(_g_dh)) SaveDesktopInfo() @@ -312,7 +313,8 @@ def handlePlayStatusMessage(self, status, data): self.messageIn.put((self.kodiPlayer is not None, json.dumps(statusMessage))) def handlePlayStopMessage(self, status, data): - FBLock(); RCLock() + FBLock() + RCLock() self.messageIn.put((True, None)) def handleSwitchToEnigma2Message(self, status, data): @@ -329,7 +331,8 @@ def handlePlayMessage(self, status, data): self.logger.error("handlePlayMessage: no data!") self.messageIn.put((False, None)) return - FBUnlock(); RCUnlock() + FBUnlock() + RCUnlock() # parse subtitles, play path and service type from data sType = 4097 From 02e5758b480cdd08ac5a6d911d6b850d52f4a0da Mon Sep 17 00:00:00 2001 From: persianpros Date: Mon, 10 May 2021 10:53:54 +0430 Subject: [PATCH 2/7] PEP8 double aggressive E251 and E252 --- src/plugin/e2utils.py | 7 +++---- src/plugin/plugin.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/plugin/e2utils.py b/src/plugin/e2utils.py index 400d1d5..3503ada 100644 --- a/src/plugin/e2utils.py +++ b/src/plugin/e2utils.py @@ -169,8 +169,7 @@ def __init__(self, session, updateIntervalInMs=500): self.updateIntervalInMs = updateIntervalInMs self.updateTimer = eTimer() self.updateTimer.callback.append(self.updateStatus) - self.__event_tracker = ServiceEventTracker(screen=self, eventmap= - { + self.__event_tracker = ServiceEventTracker(screen=self, eventmap={ iPlayableService.evBuffering: self.__evBuffering, iPlayableService.evStart: self.__evStart, iPlayableService.evStopped: self.__evStopped, @@ -369,8 +368,8 @@ def showSubservices(self): choice_list.append((subservice_ref.getName(), subservice_ref)) if numsubservices > 1: self.session.openWithCallback(self.subserviceSelected, ChoiceBox, - title = _("Please select subservice..."), list = choice_list, - selection = selection, skin_name="SubserviceSelection") + title=_("Please select subservice..."), list=choice_list, + selection=selection, skin_name="SubserviceSelection") def subserviceSelected(self, service_ref): if service_ref: diff --git a/src/plugin/plugin.py b/src/plugin/plugin.py index 46dbfa8..fa50450 100644 --- a/src/plugin/plugin.py +++ b/src/plugin/plugin.py @@ -461,7 +461,7 @@ def autoStart(reason, **kwargs): except OSError: pass SERVER = E2KodiExtServer() - SERVER_THREAD = threading.Thread(target = SERVER.serve_forever) + SERVER_THREAD = threading.Thread(target=SERVER.serve_forever) SERVER_THREAD.start() elif reason == 1: SERVER.shutdown() From 9320d66186156839b2773481f9b88bea07ee2028 Mon Sep 17 00:00:00 2001 From: persianpros Date: Mon, 10 May 2021 10:53:54 +0430 Subject: [PATCH 3/7] PEP8 double aggressive E20 and E211 --- src/plugin/e2utils.py | 4 ++-- src/plugin/plugin.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugin/e2utils.py b/src/plugin/e2utils.py index 3503ada..c6d2204 100644 --- a/src/plugin/e2utils.py +++ b/src/plugin/e2utils.py @@ -82,7 +82,7 @@ def __init__(self, default=None, cachedir='/tmp/', caching=True): self.picload.PictureData.get().append(self.setPixmapCB) def applySkin(self, desktop, parent): - attribs = [ ] + attribs = [] if self.skinAttributes is not None: for (attrib, value) in self.skinAttributes: if attrib == "default": @@ -348,7 +348,7 @@ def hideStatus(self): class InfoBarSubservicesSupport(object): def __init__(self): self["InfoBarSubservicesActions"] = HelpableActionMap(self, - "ColorActions", { "green": (self.showSubservices, _("Show subservices"))}, -2) + "ColorActions", {"green": (self.showSubservices, _("Show subservices"))}, -2) self.__timer = eTimer() self.__timer.callback.append(self.__seekToCurrentPosition) self.onClose.append(self.__timer.stop) diff --git a/src/plugin/plugin.py b/src/plugin/plugin.py index fa50450..4a8fbc8 100644 --- a/src/plugin/plugin.py +++ b/src/plugin/plugin.py @@ -159,7 +159,7 @@ def __init__(self, session, playlistCallback, nextItemCallback, prevItemCallback self.eventTracker = ServiceEventTracker(self, { - iPlayableService.evStart : self.__evStart, + iPlayableService.evStart: self.__evStart, }) self.onClose.append(boundFunction(self.session.deleteDialog, self.statusScreen)) self.onClose.append(boundFunction(Notifications.RemovePopup, self.RESUME_POPUP_ID)) From de21868b6117a0b4106d18f2bc853ec81b217af9 Mon Sep 17 00:00:00 2001 From: persianpros Date: Mon, 10 May 2021 10:53:55 +0430 Subject: [PATCH 4/7] PEP8 double aggressive E22, E224, E241, E242 and E27 --- src/plugin/plugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugin/plugin.py b/src/plugin/plugin.py index 4a8fbc8..9374055 100644 --- a/src/plugin/plugin.py +++ b/src/plugin/plugin.py @@ -230,7 +230,7 @@ def getTitle(self): except: season = -1 if season > 0 and episode > 0: - title += u" S%02dE%02d"%(season, episode) + title += u" S%02dE%02d" % (season, episode) episodeTitle = vTag.get("title") if episodeTitle: title += u" - " + episodeTitle @@ -238,7 +238,7 @@ def getTitle(self): title = vTag.get("title") or vTag.get("originaltitle") year = vTag.get("year") if year and title: - title+= u" (" + str(year) + u")" + title += u" (" + str(year) + u")" if not title: title = self.meta.get("title") if not title: @@ -428,7 +428,7 @@ def psCallback(data, retval, extraArgs): kodiProc = p.split() if kodiProc is not None: kodiPid = int(kodiProc[0]) - print "[KodiLauncher] startup: kodi is running, pid = %d , resuming..."% kodiPid + print "[KodiLauncher] startup: kodi is running, pid = %d , resuming..." % kodiPid self.resumeKodi(kodiPid) else: print "[KodiLauncher] startup: kodi is not running, starting..." From 7c0b9e04372cbc4444f13c6f8a02937d2cde6223 Mon Sep 17 00:00:00 2001 From: persianpros Date: Mon, 10 May 2021 10:53:56 +0430 Subject: [PATCH 5/7] PEP8 double aggressive E225 ~ E228 and E231 --- src/plugin/e2utils.py | 24 ++++++++++++------------ src/plugin/plugin.py | 6 +++--- src/plugin/server.py | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/plugin/e2utils.py b/src/plugin/e2utils.py index c6d2204..1ac5bc3 100644 --- a/src/plugin/e2utils.py +++ b/src/plugin/e2utils.py @@ -215,17 +215,17 @@ class InfoBarAspectChange(object): Simple aspect ratio changer """ V_DICT = { - '16_9_letterbox':{'aspect':'16:9', 'policy2':'letterbox', 'title':'16:9 ' + _("Letterbox")}, - '16_9_panscan':{'aspect':'16:9', 'policy2':'panscan', 'title':'16:9 ' + _("Pan&scan")}, - '16_9_nonlinear':{'aspect':'16:9', 'policy2':'panscan', 'title':'16:9 ' + _("Nonlinear")}, - '16_9_bestfit':{'aspect':'16:9', 'policy2':'bestfit', 'title':'16:9 ' + _("Just scale")}, - '16_9_4_3_pillarbox':{'aspect':'16:9', 'policy':'pillarbox', 'title':'4:3 ' + _("PillarBox")}, - '16_9_4_3_panscan':{'aspect':'16:9', 'policy':'panscan', 'title':'4:3 ' + _("Pan&scan")}, - '16_9_4_3_nonlinear':{'aspect':'16:9', 'policy':'nonlinear', 'title':'4:3 ' + _("Nonlinear")}, - '16_9_4_3_bestfit':{'aspect':'16:9', 'policy':'bestfit', 'title':_("Just scale")}, - '4_3_letterbox':{'aspect':'4:3', 'policy':'letterbox', 'policy2':'policy', 'title':_("Letterbox")}, - '4_3_panscan':{'aspect':'4:3', 'policy':'panscan', 'policy2':'policy', 'title':_("Pan&scan")}, - '4_3_bestfit':{'aspect':'4:3', 'policy':'bestfit', 'policy2':'policy', 'title':_("Just scale")} + '16_9_letterbox': {'aspect': '16:9', 'policy2': 'letterbox', 'title': '16:9 ' + _("Letterbox")}, + '16_9_panscan': {'aspect': '16:9', 'policy2': 'panscan', 'title': '16:9 ' + _("Pan&scan")}, + '16_9_nonlinear': {'aspect': '16:9', 'policy2': 'panscan', 'title': '16:9 ' + _("Nonlinear")}, + '16_9_bestfit': {'aspect': '16:9', 'policy2': 'bestfit', 'title': '16:9 ' + _("Just scale")}, + '16_9_4_3_pillarbox': {'aspect': '16:9', 'policy': 'pillarbox', 'title': '4:3 ' + _("PillarBox")}, + '16_9_4_3_panscan': {'aspect': '16:9', 'policy': 'panscan', 'title': '4:3 ' + _("Pan&scan")}, + '16_9_4_3_nonlinear': {'aspect': '16:9', 'policy': 'nonlinear', 'title': '4:3 ' + _("Nonlinear")}, + '16_9_4_3_bestfit': {'aspect': '16:9', 'policy': 'bestfit', 'title': _("Just scale")}, + '4_3_letterbox': {'aspect': '4:3', 'policy': 'letterbox', 'policy2': 'policy', 'title': _("Letterbox")}, + '4_3_panscan': {'aspect': '4:3', 'policy': 'panscan', 'policy2': 'policy', 'title': _("Pan&scan")}, + '4_3_bestfit': {'aspect': '4:3', 'policy': 'bestfit', 'policy2': 'policy', 'title': _("Just scale")} } V_MODES = ['16_9_letterbox', '16_9_panscan', '16_9_nonlinear', '16_9_bestfit', @@ -253,7 +253,7 @@ def __init__(self): self["aspectChangeActions"] = HelpableActionMap(self, "InfoBarAspectChangeActions", { - "aspectChange":(self.toggleAspectRatio, _("Change aspect ratio")) + "aspectChange": (self.toggleAspectRatio, _("Change aspect ratio")) }, -3) self.onClose.append(self.__onClose) diff --git a/src/plugin/plugin.py b/src/plugin/plugin.py index 9374055..aa4abf4 100644 --- a/src/plugin/plugin.py +++ b/src/plugin/plugin.py @@ -58,8 +58,8 @@ def SaveDesktopInfo(): _g_dw = getDesktop(0).size().width() _g_dh = getDesktop(0).size().height() except: - _g_dw,_g_dh = 1280,720 - print "[XBMC] Desktop size [%dx%d]" % (_g_dw,_g_dh) + _g_dw, _g_dh = 1280, 720 + print "[XBMC] Desktop size [%dx%d]" % (_g_dw, _g_dh) open("/tmp/dw.info", "w").write(str(_g_dw) + "x" + str(_g_dh)) SaveDesktopInfo() @@ -371,7 +371,7 @@ def handlePlayMessage(self, status, data): meta = {} # create Kodi player Screen - noneFnc = lambda:None + noneFnc = lambda: None self.kodiPlayer = SESSION.openWithCallback(self.kodiPlayerExitCB, KodiVideoPlayer, noneFnc, noneFnc, noneFnc, noneFnc, noneFnc) diff --git a/src/plugin/server.py b/src/plugin/server.py index 1dd4d37..2a8f8a0 100644 --- a/src/plugin/server.py +++ b/src/plugin/server.py @@ -20,7 +20,7 @@ def __init__(self, request, client_address, server): def handle(self): hlen = struct.calcsize('ibi') header = self.request.recv(hlen) - opcode, status, datalen = struct.unpack('ibi',header) + opcode, status, datalen = struct.unpack('ibi', header) if datalen > 0: data = self.request.recv(datalen) else: From 40adf833bcff927e2724a429f935bdced5c74ca3 Mon Sep 17 00:00:00 2001 From: persianpros Date: Mon, 10 May 2021 10:53:57 +0430 Subject: [PATCH 6/7] PEP8 double aggressive E301 ~ E306 --- src/plugin/e2utils.py | 8 +++++++- src/plugin/plugin.py | 18 +++++++++++++++++- src/plugin/server.py | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/plugin/e2utils.py b/src/plugin/e2utils.py index 1ac5bc3..92e97b3 100644 --- a/src/plugin/e2utils.py +++ b/src/plugin/e2utils.py @@ -26,6 +26,7 @@ def toString(text): return text return str(text) + def getAspect(): val = AVSwitch().getAspectRatioSetting() if val == 0 or val == 1: @@ -36,6 +37,7 @@ def getAspect(): r = (16 * 576, 10 * 720) return r + def getPlayPositionPts(session): service = session.nav.getCurrentService() seek = service and service.seek() @@ -43,12 +45,14 @@ def getPlayPositionPts(session): position = position and not position[0] and position[1] or None return position + def getPlayPositionInSeconds(session): position = getPlayPositionPts(session) if position is not None: position = position / 90000 return position + def getDurationPts(session): service = session.nav.getCurrentService() seek = service and service.seek() @@ -56,12 +60,14 @@ def getDurationPts(session): duration = duration and not duration[0] and duration[1] or None return duration + def getDurationInSeconds(session): duration = getDurationPts(session) if duration is not None: duration = duration / 90000 return duration + def seekToPts(session, pts): service = session.nav.getCurrentService() seek = service and service.seek() @@ -210,6 +216,7 @@ def __init__(self): self.onClose.append(self.bufferScreen.hide) self.onClose.append(self.bufferScreen.doClose) + class InfoBarAspectChange(object): """ Simple aspect ratio changer @@ -233,7 +240,6 @@ class InfoBarAspectChange(object): '4_3_letterbox', '4_3_panscan', '4_3_bestfit' ] - def __init__(self): self.postAspectChange = [] self.aspectChanged = False diff --git a/src/plugin/plugin.py b/src/plugin/plugin.py index aa4abf4..a195daa 100644 --- a/src/plugin/plugin.py +++ b/src/plugin/plugin.py @@ -29,6 +29,7 @@ class SubsSupport(object): def __init__(self, *args, **kwargs): pass + class SubsSupportStatus(object): def __init__(self, *args, **kwargs): pass @@ -52,6 +53,8 @@ def __init__(self, *args, **kwargs): SERVER_THREAD = None _g_dw, _g_dh = 1280, 720 + + def SaveDesktopInfo(): global _g_dw, _g_dh try: @@ -61,32 +64,41 @@ def SaveDesktopInfo(): _g_dw, _g_dh = 1280, 720 print "[XBMC] Desktop size [%dx%d]" % (_g_dw, _g_dh) open("/tmp/dw.info", "w").write(str(_g_dw) + "x" + str(_g_dh)) + + SaveDesktopInfo() + def FBLock(): print"[KodiLauncher] FBLock" fbClass.getInstance().lock() + def FBUnlock(): print "[KodiLauncher] FBUnlock" fbClass.getInstance().unlock() + def RCLock(): print "[KodiLauncher] RCLock" eRCInput.getInstance().lock() + def RCUnlock(): print "[KodiLauncher] RCUnlock" eRCInput.getInstance().unlock() + def kodiStopped(data, retval, extraArgs): print '[KodiLauncher] kodi stopped: retval = %d' % retval + def kodiResumeStopped(data, retval, extraArgs): print '[KodiLauncher] kodi resume script stopped: retval = %d' % retval if retval > 0: KODI_LAUNCHER.stop() + class KodiVideoPlayer(InfoBarBase, SubsSupportStatus, SubsSupport, InfoBarShowHide, InfoBarSeek, InfoBarSubservicesSupport, InfoBarAspectChange, InfoBarAudioSelection, InfoBarNotifications, HelpableScreen, Screen): skin = """ @@ -177,7 +189,6 @@ def __evStart(self): type=MessageBox.TYPE_INFO, enable_input=False) self.__timer.start(500, True) - def __seekToPosition(self): if getPlayPositionInSeconds(self.session) is None: self.__timer.start(500, True) @@ -209,6 +220,7 @@ def showAspectChanged(self): def doEofInternal(self, playing): self.close() + class Meta(object): def __init__(self, meta): self.meta = meta @@ -401,6 +413,7 @@ def kodiPlayerExitCB(self, callback=None): self.kodiPlayer = None self.subtitles = [] + class KodiLauncher(Screen): skin = """""" @@ -451,6 +464,7 @@ def stop(self): self.session.nav.playService(self.previousService) self.close() + def autoStart(reason, **kwargs): print "[KodiLauncher] autoStart - reason = %d" % reason global SERVER_THREAD @@ -467,6 +481,7 @@ def autoStart(reason, **kwargs): SERVER.shutdown() SERVER_THREAD.join() + def startLauncher(session, **kwargs): RCUnlock() global SESSION @@ -474,6 +489,7 @@ def startLauncher(session, **kwargs): global KODI_LAUNCHER KODI_LAUNCHER = session.open(KodiLauncher) + def Plugins(**kwargs): from enigma import getDesktop screenwidth = getDesktop(0).size().width() diff --git a/src/plugin/server.py b/src/plugin/server.py index 2a8f8a0..6792622 100644 --- a/src/plugin/server.py +++ b/src/plugin/server.py @@ -11,6 +11,7 @@ logging.basicConfig(level=loglevel, format='%(name)s: %(message)s',) + class KodiExtRequestHandler(SocketServer.BaseRequestHandler): def __init__(self, request, client_address, server): From ffb77bef9d97604f06ae03191d71ba854860054d Mon Sep 17 00:00:00 2001 From: persianpros Date: Mon, 10 May 2021 10:53:57 +0430 Subject: [PATCH 7/7] PEP8 double aggressive W291 ~ W293 and W391 --- src/plugin/e2utils.py | 5 ++--- src/plugin/plugin.py | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/plugin/e2utils.py b/src/plugin/e2utils.py index 92e97b3..7bda841 100644 --- a/src/plugin/e2utils.py +++ b/src/plugin/e2utils.py @@ -353,7 +353,7 @@ def hideStatus(self): # pretty much openpli's one but simplified class InfoBarSubservicesSupport(object): def __init__(self): - self["InfoBarSubservicesActions"] = HelpableActionMap(self, + self["InfoBarSubservicesActions"] = HelpableActionMap(self, "ColorActions", {"green": (self.showSubservices, _("Show subservices"))}, -2) self.__timer = eTimer() self.__timer.callback.append(self.__seekToCurrentPosition) @@ -374,7 +374,7 @@ def showSubservices(self): choice_list.append((subservice_ref.getName(), subservice_ref)) if numsubservices > 1: self.session.openWithCallback(self.subserviceSelected, ChoiceBox, - title=_("Please select subservice..."), list=choice_list, + title=_("Please select subservice..."), list=choice_list, selection=selection, skin_name="SubserviceSelection") def subserviceSelected(self, service_ref): @@ -393,4 +393,3 @@ def __seekToCurrentPosition(self): else: seekToPts(self.session, self.__playpos) del self.__playpos - diff --git a/src/plugin/plugin.py b/src/plugin/plugin.py index a195daa..bdc2726 100644 --- a/src/plugin/plugin.py +++ b/src/plugin/plugin.py @@ -242,7 +242,7 @@ def getTitle(self): except: season = -1 if season > 0 and episode > 0: - title += u" S%02dE%02d" % (season, episode) + title += u" S%02dE%02d" % (season, episode) episodeTitle = vTag.get("title") if episodeTitle: title += u" - " + episodeTitle @@ -502,4 +502,3 @@ def Plugins(**kwargs): PluginDescriptor("Kodi", PluginDescriptor.WHERE_AUTOSTART, "Kodi Launcher", fnc=autoStart), PluginDescriptor("Kodi", PluginDescriptor.WHERE_EXTENSIONSMENU, "Kodi Launcher", fnc=startLauncher), PluginDescriptor("Kodi", PluginDescriptor.WHERE_PLUGINMENU, "Kodi Launcher", icon=kodiext, fnc=startLauncher)] -