xbmc.py :  » Game-2D-3D » XBMC-MythTV » xbmcmythtv » test » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Game 2D 3D » XBMC MythTV 
XBMC MythTV » xbmcmythtv » test » xbmc.py
"""

    xbmc.py - emulator for Xbox Media Center

"""

from Tkinter import *



__author__ = 'alexpoet/bitplane'

__credits__ = 'XBMC TEAM.'

__date__ = '11 July 2004'

__version__ = '0.1a'



# define playlist types

PLAYLIST_MUSIC      = 0

PLAYLIST_MUSIC_TEMP = 1

PLAYLIST_VIDEO      = 2

PLAYLIST_VIDEO_TEMP = 3



TRAY_OPEN                 = 16

DRIVE_NOT_READY           = 1

TRAY_CLOSED_NO_MEDIA      = 64

TRAY_CLOSED_MEDIA_PRESENT = 96





# functions...



def restart():

    """

        restart() -- Restart Xbox.

        INCOMPLETE: how do you quit python?

    """

    raise KeyboardInterrupt



def shutdown():

    """

        shutdown() -- Shutdown the xbox

        INCOMPLETE: how do you quit python?

    """

    raise KeyboardInterrupt



def dashboard():

    """

        dashboard() -- Boot to dashboard.

        INCOMPLETE: how do you quit python?

    """

    raise KeyboardInterrupt



def executescript(script):

    """

        executescript(string) -- Execute a python script.



        example:

          - executescript('q:\scripts\update.py')

    """

    pass



def getCpuTemp():

    """

        getCpuTemp() -- Returns the current cpu tempature.

        INCOMPLETE - hard coded, hardly worth the effort

    """

    return 20



def getDVDState():

    """

        getDVDState() -- Returns the dvd state.



        return values are:

 

          - 16 : xbmc.TRAY_OPEN

          - 1  : xbmc.DRIVE_NOT_READY

          - 64 : xbmc.TRAY_CLOSED_NO_MEDIA

          - 96 : xbmc.TRAY_CLOSED_MEDIA_PRESENT



        INCOMPLETE - always returns DRIVE_NOT_READY

    """

    return DRIVE_NOT_READY



def getFreeMem():

    """

        getFreeMem() -- Returns free memory as a string.

    """

    pass



def getIPAddress():

    """

        getIPAddress() -- Returns the current ip adres as string.

        INCOMPLETE - hard coded loopback

    """

    return "127.0.0.1"



def getLanguage():

    """

        getLanguage() -- Returns the active language as string.

        INCOMPLETE - investigation needed

    """

    return "English"



def getLocalizedString(id):

    """

        getLocalizedString(int id) -- Returns a Localized 'unicode string'.

        See the xml language files in /language/ which id you need for a string

        

        INCOMPLETE - returns ID no as string

    """

    return str(id)



def getSkinDir():

    """

        getSkinDir() -- Returns the active skin directory.

 

        Note, this is not the full path like 'q:\skins\MediaCenter', 

        but only 'MediaCenter'



        INCOMPLETE - Hard coded

    """

    #return "Project Mayhem"

    #return "Project Mayhem II"

    return "Project Mayhem III"



def output(s):

    """

        output(string) -- Write a string to the debug window.

    """

    print s



# classes



class Keyboard:

    """

        Keyboard([string default]) -- Creates a new Keyboard object with default text

                                      if supplied.

    """

    # should this be __init__(self, text=None): ?

    def __init__(self, text = ''):

        import time

        time.sleep(1)

        self.confirmed = False

        self.root = Toplevel()

        box = Frame(self.root)

        box.pack(expand = YES, fill = BOTH)

        self.ent = Entry(box)

        self.ent.insert(0, text)

        self.ent.pack(side = TOP, fill = X)

        self.ent.focus()

        self.ent.bind("<Return>", self.__ok)

        Button(box, text = "Accept (Y-button)", command = self.__ok).pack(side = LEFT)

        Button(box, text = "Cancel (B-button)", command = self.__cancel).pack(side = RIGHT)

        self.root.focus_set()

        self.root.grab_set()

        self.root.wait_window()

        

    def __ok(self, event = None):

        """

            INTERNAL

        """

        self.confirmed = True

        self.text = self.ent.get()

        self.root.destroy()



    def __cancel(self):

        """

            INTERNAL

        """

        self.confirmed = False

        self.text = ""

        self.root.destroy()



    def getText(self):

        """

            getText() -- Returns the user input.

        """

        return self.text



    def doModal(self):

        """

            doModal() -- Show keyboard and wait for user action.

            INCOMPLETE

        """

        pass

        

    def isConfirmed(self):

        """

            isConfirmed() -- Returns False if the user cancelled the input.

        """

        return self.confirmed

        

    def setDefault(self, text):

        """

            setDefault(string text) -- Set new text that is displayed as default.

        """

        self.ent.insert(0, text)

        

class PlayList:

    """

        PlayList(int playlist) -- retrieve a reference from a valid xbmc playlist

        int playlist can be one of the next values:

          - 0 : xbmc.PLAYLIST_MUSIC

          - 1 : xbmc.PLAYLIST_MUSIC_TEMP

          - 2 : xbmc.PLAYLIST_VIDEO

          - 3 : xbmc.PLAYLIST_VIDEO_TEMP

    """

    def __init__(self,playlist):

        # playlist is "x" in doc strings

        self.x = []



    def __getitem__(self,y):

        return self.x[y]



    def __len__(self):

        return len(x)



    def add(self, filename, description="",duration=0):

        """

            add(filename[, description, duration]) -- Add's a new file to the playlist.

        """

        self.x.append(PlayListItem())

        i = len(self.x) -1 

        self.x[i].__filename    = filename

        self.x[i].__description = description

        self.x[i].__duration    = duration

        

    def clear(self):

        """

            clear() -- clear all items in the playlist.

        """

        for i in range(0,len(self.x)):

            del self.x[len(self.x)-1]



    def load(self,filename):

        """

            load(filename) -- Load a playlist.

 

            clear current playlist and copy items from the file to this Playlist

            filename can be like .pls or .m3u ...

            returns False if unable to load playlist



            INCOMPLETE

        """

        pass



    def remove(self,filename):

        """

            remove(filename) -- remove an item with this filename from the playlist.



            INVESTIGATE: should this raise an error if filename not found?

                         should it remove dupes?

        """

        f = filename.upper()

        for i in range(0,len(self.x)-1):

            if self.x[i].__filename.upper() == f:

                del self.x[i]

                return



    def shuffle(self):

        """

            shuffle() -- shuffle the playlist.

            

            INCOMPLETE

        """

        pass

    

class PlayListItem:

    """

        PlayListItem() -- Creates a new PlaylistItem which can be added to a PlayList.

    """

    def __init__(self):

        self.__filename     = ""

        self.__description  = ""

        self.__duration     = 0

    def getdescription(self):

        """

            getdescription() -- Returns the description of this PlayListItem.

        """

        return self.__description

    

    def getduration(self):

        """

            getduration() -- Returns the duration of this PlayListItem.

        """

        return  self.__duration

    

    def getfilename(self):

        """

            getfilename() -- Returns the filename of this PlayListItem.

        """

        return self.__filename

    

class Player:

    """

        Player() -- Creates a new Player with as default the xbmc music playlist.

        INCOMPLETE - stubbed for now, Winamp support planned

    """

    def __init__(self):

        # create default playlist

        pass

    

    def isPlaying( self ):

        return False



    def pause(self):

        """

            pause() -- Pause playing.

        """

        pass

    

    def play(self,item=None):

        """

            play([item]) -- Play this item.

            

            item can be a filename or a PlayList.

            If item is not given then the Player will try to play the current item

            in the current playlist.

        """ 

        pass

    

    def playnext(self):

        """

            playnext() -- Play next item in playlist.

        """

        pass

    

    def playprevious(self):

        """

            playprevious() -- Play previous item in playlist.

        """

        pass

    

    def stop(self):

        """

            stop() -- Stop playing.

        """

        pass



    def getTime(self):

        return 0



    def getTotalTime(self):

        return 0



    def seekTime(self, t):

        pass



# set up if not ready

#if not ("Ready" in dir(xbmc)):

#    Ready = True

    # Set up q:\

    # read xboxmediacenter.xml

    # read settings

    # open winamp, read playlist

    







www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.