Exemple #1
0
    def ProcessFolderList(self, url):
        """ NOT USER EDITABLE
        Accepts an URL and returns a list of items with at least name & url set
        Each item can be filled using the ParseFolderItem and ParseVideoItem 
        Methodes
        """

        if not self.pluginMode:
            guiController = guicontroller.GuiController(self)
            guiController.ClearEpisodeLists()
            guiController.ShowData(self.folderHistory[0])

        preItems = []
        folderItems = []
        videoItems = []
        pageItems = []

        if (url == "searchSite"):
            logFile.debug("Starting to search")
            return self.SearchSite()

        data = uriHandler.Open(url)

        # first of all do the Pre handler
        (data, preItems) = self.PreProcessFolderList(data)

        # then process folder items.
        if not self.folderItemRegex == '':
            folders = common.DoRegexFindAll(self.folderItemRegex, data)
            for folder in folders:
                folderItems.append(self.CreateFolderItem(folder))

        # sort by name
        folderItems.sort(lambda x, y: cmp(x.name.lower(), y.name.lower()))

        # now process video items
        if not self.videoItemRegex == '':
            videos = common.DoRegexFindAll(self.videoItemRegex, data)
            for video in videos:
                videoItems.append(self.CreateVideoItem(video))

        # sort
        #videoItems.sort()

        # now process page navigation if a pageNavigationIndication is present
        if not self.pageNavigationRegex == '':
            pageItems = self.ProcessPageNavigation(data)

        return preItems + folderItems + videoItems + pageItems
Exemple #2
0
    def CtMnPlayDVDPlayer(self, selectedIndex):
        item = self.listItems[selectedIndex]
        if not item.complete:
            item = self.UpdateVideoItem(item)
            # check if the list has not changed during upate:
            #if item.guid == self.listItems[_position].guid:
            if item.Equals(self.listItems[self.getCurrentListPosition()]):
                logFile.info("Updating item (GUIDs match)")
                self.listItems[self.getCurrentListPosition()] = item
            else:
                logFile.error("Aborting Update because of GUID mismatch")
        logFile.info("Starting playback of %s (mediaurl=%s) using dvdplayers",
                     item.name, item.mediaurl)

        guiController = guicontroller.GuiController(self)
        guiController.ShowData(item)

        self.PlayVideoItem(item, "dvdplayer")
Exemple #3
0
    def LoadChannels(self):
        data = uriHandler.Open(
            "http://code.google.com/p/xot-uzg/downloads/list?q=label:AutoUpdate",
            pb=False)
        channels = common.DoRegexFindAll(
            'href="detail\?name=([^&]+)[^"]+">([^<]+)</a>[^!]+[^>]+>[^>]+>([^<]+)</a>',
            data)
        guiController = guicontroller.GuiController(self)

        for channel in channels:
            item = common.clistItem(
                channel[0],
                "http://xot-uzg.googlecode.com/files/%s" % channel[0])
            item.description = common.ConvertHTMLEntities(channel[1])
            item.icon = guiController.GetImageLocation("xot_updateicon.png")
            item.date = channel[2]
            self.updateItems.append(item)
            item = xbmcgui.ListItem(channel[0], channel[2], item.icon,
                                    item.icon)
            self.addItem(item)
Exemple #4
0
import tkinter
from tkinter import *
import guicontroller

root = Tk()
frame = Frame(root, width=500, height=300)
frame.pack()
controllerGui = guicontroller.GuiController()
C = tkinter.Canvas(frame, height=100, width=400)
C.pack()
C.create_text(200,
              20,
              text="Pengolahan Citra Digital",
              font='Helvetica 18 bold')
C.create_text(200,
              50,
              text="Charly Haholongan Situmorang",
              font='Helvetica 14 bold')
C.create_text(200, 80, text="1301150023", font='Helvetica 14 bold')
bottomframe = Frame(root)
bottomframe.pack(side=BOTTOM)

blackbutton = Button(bottomframe,
                     text="Browse Photos",
                     fg="black",
                     command=controllerGui.browse_photoButton)
blackbutton.pack(side=BOTTOM)
root.mainloop()

#==========Pengolahan Citra Digital=============
# Nama : Charly Haholongan Situmorang
Exemple #5
0
 def ShowChannelInfo(self):
     guiControler = guicontroller.GuiController(self)
     guiControler.ShowChannelInfo(self.activeChannelGUI)
     return
Exemple #6
0
    def onUpDown(self, ignoreDisabled=False):
        """ NOT USER EDITABLE
        Action Method for handling selecting. If the ignoreDisalbe is set to True
        it makes the script ignore self.onUpDownUpdateEnabled and update anyway! 
        """
        logFile.debug("OnKeyUp/KeyDown Detected")
        try:
            # get the item that is focused
            _position = self.getCurrentListPosition()
            _item = self.listItems[_position]
            guiController = guicontroller.GuiController(self)

            if _item.complete:
                #item is complete. Just show
                logFile.debug("No OnKeyUp/KeyDown for a complete item")
                guiController.ShowData(self.listItems[_position])
                return

            if _item.type == "folder" or _item.type == "append":
                #item is folder.
                logFile.debug("No OnKeyUp/KeyDown for a folder or append item")
                guiController.ShowData(self.listItems[_position])
                return

            if _item.complete == False and _item.type == "video" and (
                    not self.onUpDownUpdateEnabled and not ignoreDisabled):
                # item is not complete, but the onupdown is disabled and we don't have to ignore that
                # just show the data
                logFile.debug(
                    "Item is not complete, but the onupdown is disabled and we don't have to ignore that. Only showing data"
                )
                guiController.ShowData(self.listItems[_position])
                return

            if _item.complete == False and _item.type == "video" and (
                    self.onUpDownUpdateEnabled or ignoreDisabled):
                # if video item and not complete, do an update if not already busy

                #===============================================================================
                # Locking block
                #===============================================================================
                # aquire lock so that all new timers in the keyUp/Down actions will
                # be blocked! A timer is set to call the onUpDown again after waiting
                logFile.debug("1.==== Trying to acquire a lock")
                if (not self.videoUpdateLock.acquire(0)):
                    logFile.debug("2.==== Lock was already active")
                    try:
                        self.timerUpDown.cancel()
                    except:
                        pass
                    logFile.debug("Resetting the timer from within onUpDown")
                    self.timerUpDown = threading.Timer(self.timerTimeOut,
                                                       self.onUpDown)
                    self.timerUpDown.start()
                    return
                logFile.debug("2.==== Lock Acquired")
                #==============================================================================
                # Actual action happens now:
                logFile.debug("Item '%s' not completed yet. Updating Video",
                              _item.name)

                #display please wait:
                guiController.ShowData(self.folderHistory[0])

                _item = self.UpdateVideoItem(_item)
                # if the mediaUrl is not filled: item is not complete
                if _item.mediaurl == "":
                    _item.complete = False

                # check if the list has not changed during upate:
                if _item.Equals(self.listItems[_position]):
                    logFile.info("Updating item (GUIDs match)")
                    self.listItems[_position] = _item
                else:
                    logFile.error(
                        "Aborting Update because of GUID mismatch\n(%s and %s)",
                        _item.guid, self.listItems[_position].guid)

                # release lock
                logFile.debug("3.==== UnLocking the lock")

                guiController.ShowData(self.listItems[_position])
                self.videoUpdateLock.release()
                #===============================================================================
                # Locking block End
                #===============================================================================
            else:
                #if nothing matched
                logFile.debug("OnUpDown: does not know what to do")
                return
        except:
            try:
                # release lock
                logFile.debug("3.==== Unlocking the lock after an excpetion")
                self.videoUpdateLock.release()
            except:
                pass

            logFile.critical("Cannot handle KeyUp/Down", exc_info=True)
Exemple #7
0
    def onClick(self, controlID):
        """
        Catching of clicking (Select/OK)
        """
        logFile.debug("OnClick detected on controlID = %s", controlID)

        try:
            # check if the Episode List is active
            logFile.debug("Trying to determine what to do with the onClick")
            guiController = guicontroller.GuiController(self)

            if controlID == controls.EP_LIST or controlID == controls.PG_LIST:
                # get the episodelist position
                position = self.getCurrentListPosition()

                # store the position
                self.currentPosition = position

                if controlID == controls.PG_LIST:
                    # a page was clicked!
                    logFile.debug("OnClick detected on pageList")
                    pagePos = self.getControl(
                        controls.PG_LIST).getSelectedPosition()

                    # get the item, therefore we need to filter the items for pageitems
                    pageItems = []
                    for item in self.listItems:
                        if item.type == "page":
                            pageItems.append(item)

                    item = pageItems[pagePos]
                else:
                    logFile.debug("OnClick detected on EPList")
                    item = self.listItems[position]

                # Determine type of item
                if item.type == 'video':
                    # if not complete, update
                    logFile.debug("Detected Video file")
                    if not item.complete:
                        item = self.UpdateVideoItem(item)
                        # if the mediaUrl is not filled: item is not complete
                        if item.mediaurl == "":
                            item.complete = False

                        # check if the list has not changed during upate:
                        #if item.guid == self.listItems[position].guid:
                        if item.Equals(self.listItems[position]):
                            logFile.info("Updating item (GUIDs match)")
                            self.listItems[position] = item
                        else:
                            logFile.error(
                                "Aborting Update because of GUID mismatch")
                    logFile.info("Starting playback of %s (mediaurl=%s)",
                                 item.name, item.mediaurl)
                    guiController.ShowData(item)
                    self.PlayVideoItem(item)
                elif item.type == 'folder' or item.type == 'page':
                    logFile.debug(
                        "Detected Folder or Page\nAppending current selected position (%s) to history.",
                        position)

                    # remember the selected position
                    self.folderHistorySelectedPosition.append(position)

                    # append the item to the history
                    self.folderHistory.append(item)

                    # add content items to the selected item
                    item.items = self.ProcessFolderList(item.url)

                    # make those items the listItems
                    self.listItems = item.items

                    # display items
                    guiController.DisplayPageNavigation(self.listItems)
                    guiController.DisplayFolderList(self.listItems, 0)

                elif item.type == 'append':
                    logFile.debug("Detected Appendable Folder on position %s",
                                  position)

                    #read the currently showing parentitem and it's childitems
                    parentItem = self.folderHistory[-1]

                    #get new items
                    items = self.ProcessFolderList(item.url)

                    #append them to the childitems of the parentitem
                    self.AppendItemsAt(parentItem.items, items, position)

                    #sort them or not

                    #show them and highlight the current selection
                    self.listItems = parentItem.items
                    guiController.DisplayFolderList(self.listItems, position)
                    self.onUpDown(True)
                else:
                    logFile.warning("Error updating %s (%s) for %s", item.name,
                                    item.type, self.channelName)

            else:
                logFile.warning(
                    "ControlID (%s) was not recognised! No action taken",
                    controlID)
        except:
            logFile.critical("On Click error showing episodes", exc_info=True)
Exemple #8
0
    def onAction(self, action):
        """ NOT USER EDITABLE
        Action Method for handling all actions except the clicking. This one should
        only be inherited, not overwriten
        """
        try:
            if not action.getId() in controls.ACTION_MOUSE_MOVEMENT:
                logFile.debug(
                    "onAction (with buttonid=%s and id=%s) detected (ThrdID=%s)",
                    action.getButtonCode(), action.getId(), thread.get_ident())

            if action in controls.ACTION_UPDOWN:
                if (self.getFocusId() == controls.EP_LIST):
                    try:
                        logFile.debug(
                            "Cancelling and starting onKeyUpDown timer")
                        # cancel the timer is present
                        try:
                            self.timerUpDown.cancel()
                        except:
                            pass
                        # start a new one
                        self.timerUpDown = threading.Timer(
                            self.timerTimeOut, self.onUpDown)
                        self.timerUpDown.start()
                    except:
                        logFile.critical("Error in locking mechanism")

            elif action == controls.ACTION_PARENT_DIR or action == controls.ACTION_PREVIOUS_MENU:
                try:
                    logFile.debug("Removing items from historystack")
                    self.folderHistory.pop()

                    # release the video update lock if present
                    try:
                        self.videoUpdateLock.release()
                    except:
                        # if it wasn't locked, pass the exception
                        pass

                    if self.folderHistory == []:
                        self.onExit()
                    else:
                        # go back an folder, clear list, process the folder and stuff the
                        # content back in the list
                        self.listItems = self.folderHistory[-1].items
                        if len(self.listItems) < 1:
                            # the caching did not work. Start retrieving it
                            self.listItems = self.ProcessFolderList(
                                self.folderHistory[-1].url)

                        guiController = guicontroller.GuiController(self)
                        guiController.DisplayFolderList(
                            self.listItems,
                            self.folderHistorySelectedPosition.pop())
                        guiController.DisplayPageNavigation(self.listItems)

                except:
                    logFile.critical(
                        "Cannot perform a good BACK action. Closing!",
                        exc_info=True)
                    self.onExit()

#            elif action == controls.ACTION_SELECT_ITEM:
#                self.onClick(self.getFocusId())

            elif action in controls.ACTION_CONTEXT_MENU_CONTROLS:  # and self.keysLocked < 1:
                logFile.debug("showing contextmenu")
                self.onActionFromContextMenu()

            else:
                pass
                #logFile.warning("Action %s on ControlID %s was not recognised! No action taken", action, self.getFocus())
        except:
            logFile.warning('Action Failed, or could not determine action',
                            exc_info=True)
Exemple #9
0
    def onInit(self):
        """ NOT USER EDITABLE
        Initialisation of class after the GUI has been loaded. This happens every
        time. Triggered by doModal in the ShowEpisodeWindow Methode
        """
        try:
            logFile.info("onInit(): Window Initalized for %s", self.moduleName)
            if not self.windowInitialised:
                logFile.debug("Initializing %s Gui for the first time",
                              self.channelName)
                guiController = guicontroller.GuiController(self)

                # set background
                if self.getResolution(
                ) in controls.RESOLUTION_16x9 and self.backgroundImage16x9 != "":
                    self.getControl(controls.EP_BACKGROUND).setImage(
                        self.backgroundImage16x9)
                    logFile.debug("Resolution=%s, %s", self.getResolution(),
                                  self.backgroundImage16x9)

                elif self.getResolution(
                ) in controls.RESOLUTION_4x3 and self.backgroundImage != "":
                    self.getControl(controls.EP_BACKGROUND).setImage(
                        self.backgroundImage)
                    logFile.debug("Resolution=%s, %s", self.getResolution(),
                                  self.backgroundImage)

                # make sure the history is cleared!
                logFile.debug("Clearing Folder History")
                del self.folderHistory[:]
                del self.folderHistorySelectedPosition[:]

                # add initialUri to root and give it the default image and no description.
                # the latter two are used for clearing the fields while loading a new list
                _tmpItem = common.clistItem("", self.initialUri)
                _tmpItem.description = "Please wait while loading data"
                _tmpItem.thumb = self.noImage
                guiController.ShowData(_tmpItem)
                self.folderHistory.append(_tmpItem)
                self.folderHistorySelectedPosition.append(0)

                # logging on
                logFile.debug("LogonCheck")
                self.loggedOn = self.LogOn(self.userName, self.passWord)

                #make sure keys are unlocked upon init
                #self.keysLocked = 0

                if not self.loggedOn:
                    logFile.error('Not logged on...exiting')
                    self.close()
                else:
                    # create new rootItem and fetch it's items
                    rootItem = common.clistItem("root", self.initialUri)
                    rootItem.items = self.ProcessFolderList(self.initialUri)
                    rootItem.thumb = self.noImage

                    # clear history and add the rootitem
                    del self.folderHistory[:]
                    self.folderHistory.append(rootItem)

                    # now display the items.
                    self.listItems = rootItem.items

                    guiController = guicontroller.GuiController(self)
                    guiController.DisplayPageNavigation(self.listItems)
                    guiController.DisplayFolderList(self.listItems, 0)

                    self.windowInitialised = True

                logFile.debug("%s Gui has been initialised for the first time",
                              self.channelName)
            else:
                logFile.debug("%s GUI window already Initialized",
                              self.channelName)

                if self.getControl(controls.EP_LIST).size() < 1:
                    logFile.info(
                        "Somehow the list was cleared...filling it again")
                    guiController = guicontroller.GuiController(self)
                    guiController.DisplayPageNavigation(self.listItems)
                    guiController.DisplayFolderList(self.listItems,
                                                    self.currentPosition)

        except:
            logFile.critical("Error initialising the %s Window.",
                             self.channelName,
                             exc_info=True)