コード例 #1
0
 def index(self):
     # look up in client profiles to get homePage.
     if self.homeTemplate:
         result = ClientProfiles.makeStandardResponse( cherrypy.request, self.homeTemplate )
     else:
         result = ClientProfiles.makeStandardResponse( cherrypy.request, "welcome" )
     result["now"] = time.ctime()
     return result
コード例 #2
0
    def mediapanel(self, **args):
        result = ClientProfiles.makeStandardResponse( cherrypy.request, "mediapanel" )
        # extract any parameters from the URL and add to the dictionary.
        for arg in args:
            result[arg] = args[arg]

        return result
コード例 #3
0
ファイル: Media.py プロジェクト: AndyThirtover/wb_gateway
    def client(self,rid):
        rid = int(rid)
        if not self._clients.has_key(rid):
            return self.clients()   # no longer present.

        result = ClientProfiles.makeStandardResponse( cherrypy.request, "mediaclient" )

        result["rid"] = rid
        result["def_folder"] = ""   # blank
        result["sid"] = ""
        srvc = self._servers.default_server_for_renderer(device_name(self._clients[rid]))
        if srvc:
            result["sid"] = srvc._server_id
            result["def_folder"] = srvc.get_default_container_id()
        result["limit"] = 50

        # udn needed so client can pick up the correct event set.
        result["udn"] = self._clients[rid].device.get_id()
        result["name"] = device_name(self._clients[rid])
        result["hasTransport"] = True   # play,pause,position etc.
        result["hasRenderer"] = True    # volume
        result["showServers"] = True    # so can select tracks etc.
        self.add_clients( result )

        return result
コード例 #4
0
    def showlist( self ):
        """
        Return status of a media server
        """
        result = ClientProfiles.makeStandardResponse( cherrypy.request, "StreamVideoList" )

#        loc = config.get('/video')['static_filter.dir']
        loc = cherrypy.config.get('static_filter.dir', '/var/www/video', False, '/video')

        if loc:
            mediaFiles = listdir( loc )
            mediaDict = {}
            if mediaFiles:
                idx = 0
                for fil in mediaFiles:
                    if isfile( "%s/%s" % (loc,fil) ):
                        mediaDict[str(idx)] = {'title':fil, 'location':'/video/%s' % quote(fil) }
                        idx = idx + 1

            self.videoTracks = mediaDict

        result['videoTracks'] = self.videoTracks
        result['height'] = 400
        result['width'] = 800
        result['server'] = self.serverBaseUrl

        self.__log.debug( 'list %s' % (result,) )
        return result
コード例 #5
0
    def panels(self):
        result = ClientProfiles.makeStandardResponse( cherrypy.request )

        def selectPanelName((_,nam)): 
            return nam[:-4]

        pattern = re.compile( r'^.+\.xml$' )
        c = CollectFiles("../resources/paneldef/",pattern,recursive=False)
        result['baseuri'] = turbogears.url("/")+"panel/"
        result['panels'] = map(selectPanelName,c)
        return result
コード例 #6
0
ファイル: Media.py プロジェクト: AndyThirtover/wb_gateway
    def showqueue(self, rid):
        rid = int(rid)
        id = None
        srvc = self._servers.default_server_for_renderer(device_name(self._clients[rid]))
        if srvc:
            id = srvc.get_default_container_id()

        result = ClientProfiles.makeStandardResponse( cherrypy.request, "showqueue" )
        self.generate_list(result, rid, id, 0, sys.maxint )

        self.log_result(result)

        return result
コード例 #7
0
ファイル: Schedule.py プロジェクト: AndyThirtover/wb_gateway
    def list(self, *args):
        """
        return a schedule, single parameter as name, if not given return "default"
        """
        result = ClientProfiles.makeStandardResponse( cherrypy.request, "schedule" )

        result["scheduleName"] = "default"
        if len(args) > 0:
            result["scheduleName"] = args[0]

        _log.debug( "list result %s" % ( result ) )

        return result
コード例 #8
0
    def templatex(self, *args):
        """
        This function is used to return an arbitrary template used as
        a static page, but wrapped with the common header and footer
        elements.
        """
        # will set tg_template
        result = ClientProfiles.makeStandardResponse( cherrypy.request, string.join(args,'.') )

        result["tg_format"] = "xml"
#        result["tg_template"] = 'WebBrickGateway.templates.'+string.join(args,'.')

        cherrypy.response.headerMap['Refresh'] = "30"

        return result
コード例 #9
0
ファイル: Webbrick.py プロジェクト: AndyThirtover/wb_gateway
    def default(self, *args):
        result = ClientProfiles.makeStandardResponse( cherrypy.request, "commanddone" )

        cherrypy.response.headerMap["cache-control"] = "no-cache"

        wbaddr = args[0]    # Ip or DNS address
        # see whether we can map webbrick node names to ip address
        if self._namecache:
            ip = self._namecache.getIpAddress( wbaddr )
            if ip:
                wbaddr = ip

        wbtype = args[1]    # channel type? command code (should be 2 chars)
        wbchan = args[2]    # channel number
        wbval = ""
        if len(args) > 3:
            wbval = args[3]

        if wbtype == "DI":
            cmd = "DI"+wbchan
        elif wbtype == "DO":
            if wbval == "on":
                cmd = "DO"+wbchan+";N" # On
            elif wbval == "toggle":
                cmd = "DO"+wbchan+";T" # toggle
            else:
                cmd = "DO"+wbchan+";F" # Off
        else:
            # Default: channel is command, 
            # if value is non-empty: append to command
            cmd = wbtype
            if wbchan != "":
                cmd += wbchan
                for xtra in args[3:]:
                    cmd += ";" + xtra

        self._log.debug( "Sending Command %s" % cmd )
        result['wbtype'] = wbtype
        result['wbchan'] = wbchan
        result['wbval'] = wbval
        result['result'] = result

        try:
            h = SendHTTPCmd(wbaddr,cmd)
            if not h:
                raise cherrypy.HTTPError(400,"WebBrick command failed ("+wbaddr+","+wbchan+","+cmd+")")
        except Exception, ex:
            result['result'] = "Failed"
コード例 #10
0
    def template(self, *args):
        """
        This function is used to return an arbitrary template used as
        a static page, but wrapped with the common header and footer
        elements.
        """
        # will set tg_template
        result = ClientProfiles.makeStandardResponse( cherrypy.request, string.join(args,'.') )
        if result.has_key("tg_format") and result["tg_format"] == "xml":
            #cherrypy.response.headers['Content-Type'] = "text/xml"
            cherrypy.response.headerMap['Content-Type'] = "text/xml"

        cherrypy.response.headers['Content-Type'] = "text/xml"
        cherrypy.response.headerMap['Content-Type'] = "text/xml"

        return result
コード例 #11
0
    def status( self, medianame='name-required', status='item-required' ):
        """
        Return status of a media server
        """
        result = ClientProfiles.makeStandardResponse( cherrypy.request )

        self.__log.debug( 'MediaAccess.status %s, %s ' % (medianame, status) )
        result['stserr'] = None
        result['mediaName'] = medianame

        try :
            if ( status == 'vol' ):
                xmlStr = MediaSet.volume( self, medianame )
            elif ( status == 'playlist' ):
                 xmlStr = MediaSet.playlist( self, medianame )
            elif ( status == 'playlists' ):
                xmlStr = MediaSet.playlists( self, medianame )
            elif ( status == 'position' ):
                xmlStr = MediaSet.status( self, medianame )
            else:
                xmlStr = MediaSet.status( self, medianame )
            self.__log.debug( '%s:%s - xmlString %s' % (medianame, status, xmlStr) )
            xml = parseXmlString( xmlStr )

            if ( status == 'position' ):
                result['position'] = getNamedNodeText( xml, 'position' )
                result['duration'] = getNamedNodeText( xml, 'duration' )

            elif ( status == 'vol' ):
                result['vol'] = getNamedNodeText( xml, status )

            elif ( status == 'playlist' ):
                result['playlist'] = getElemXml( getNamedElem( xml, status ) )

            elif ( status == 'playlists' ):
                result['playlists'] = getElemXml( getNamedElem( xml, status ) )

            elif ( status == 'track' ):
                result['track'] = getNamedNodeText( xml, status )

            else:
                result[str(status)] = getNamedNodeText( xml, status )
        except Exception, ex :
            self.__log.exception( 'Error %s, %s ' % (medianame, status) )
            result['stserr'] = "unknown"
コード例 #12
0
    def embed( self, trackId='0' ):
        """
        Return status of a media server
        """
        result = ClientProfiles.makeStandardResponse( cherrypy.request, "StreamVideo" )

        # '/static/video/BrokenBowPart1.avi'
        title = self.videoTracks[trackId]['title']
        relUrl = self.videoTracks[trackId]['location']

        result['mediaUrl'] = relUrl
        result['mediatitle'] = title,
        result['height'] = 400,
        result['width'] = 720,
        result['server'] = self.serverBaseUrl

        self.__log.debug( 'embed %s' % (result,) )
        return result
コード例 #13
0
ファイル: SendEvent.py プロジェクト: AndyThirtover/wb_gateway
    def default(self, *args):
        result = ClientProfiles.makeStandardResponse( cherrypy.request, "commanddone" )

        cherrypy.response.headerMap["cache-control"] = "no-cache"
        uri = string.join( args, "/" )
        type = u'http://id.webbrick.co.uk/events/uri'
        other_data = dict()

        for k in cherrypy.request.params:
            if k == "type":
                type = cherrypy.request.params[k]
            else:
                other_data[k] = cherrypy.request.params[k]

        if len(other_data) == 0:
            other_data = None
        self._router.publish( "SendEventLocal", Event( type, uri, other_data ) )

        return result
コード例 #14
0
ファイル: Media.py プロジェクト: AndyThirtover/wb_gateway
    def list(self, rid, id, offset, limit):
        #
        # return a list of entries
        # if id is none then list the server sources.
        # else it a server-id:container-id.
        # 
        # Output is a list of items
        # and the id of the container it is from.
        #
	#TODO create breadcrumb trail
	# refresh containers. May be better to get UPNP classes to handle this trail
	#
        _log.debug( "list id %s", id )

        result = ClientProfiles.makeStandardResponse( cherrypy.request, "mediabrowse" )
        self.generate_list(result, rid, id, int(offset), int(limit) )

        self.log_result(result)

        return result
コード例 #15
0
ファイル: Media.py プロジェクト: AndyThirtover/wb_gateway
    def zonelink(self, rid ):
        rid = int(rid)
        if not self._clients.has_key(rid):
            return self.clients()   # no longer present.

        result = ClientProfiles.makeStandardResponse( cherrypy.request, "mediazonelink" )

        result["rid"] = rid

        # udn needed so client can pick up the correct event set.
        result["udn"] = self._clients[rid].device.get_id()
        result["name"] = device_name(self._clients[rid])

        result["clients"] = {}
        for k in self._clients:
            clnt = self._clients[k]
            if clnt and k <> rid:   # exclude self.
                result["clients"][k] = device_name(clnt)

        # create list of zones
        return result
コード例 #16
0
ファイル: Webbrick.py プロジェクト: AndyThirtover/wb_gateway
 def walkwb(self, *args):
     result = ClientProfiles.makeStandardResponse( cherrypy.request, "walkwb" )
     return self.knownWebBricksStatus(result)
コード例 #17
0
ファイル: Webbrick.py プロジェクト: AndyThirtover/wb_gateway
    def known(self, *args):
        result = ClientProfiles.makeStandardResponse( cherrypy.request, "knownWebbricks" )

        known = list()
        result['webbricks'] = known
        return result
コード例 #18
0
 def change(self, *args):
     ClientProfiles.changeClientProfile( cherrypy.request )
     result = ClientProfiles.makeStandardResponse( cherrypy.request, "userinterface" )
     return result
コード例 #19
0
ファイル: Schedule.py プロジェクト: AndyThirtover/wb_gateway
    def index(self,*args):
        result = ClientProfiles.makeStandardResponse( cherrypy.request, "schedulelist" )

        result["schedules"] = cherrypy.config.configs["schedules"]

        return result
コード例 #20
0
 def default(self, *args):
     result = ClientProfiles.makeStandardResponse( cherrypy.request, "userinterface" )
     return result
コード例 #21
0
ファイル: Media.py プロジェクト: AndyThirtover/wb_gateway
    def clients(self):
        result = ClientProfiles.makeStandardResponse( cherrypy.request, "mediaclientlist" )

        self.add_clients( result )

        return result
コード例 #22
0
    def start(self):
        log_versions()
        # TODO         validateTemplateDirectory() on WebBrickGateway.templates
        persistFile = turbogears.config.get("client_profiles", None, False, "gateway" )

        ClientProfiles.load( persistFile )

        self.homeTemplate = turbogears.config.get("homepage", None, False, "gateway" )

        cfgStr = turbogears.config.get("templateDirectory", None, False, "gateway" )
        if cfgStr:
            _log.info( "additional template directory %s" % (cfgStr) )
            validateTemplateDirectory( cfgStr )

            #WbConfigSettings.addTemplateDir( cfgStr )
            sys.path.insert( 1, cfgStr )
            import kid
            _log.info( "Kid Paths %s"  % (str(kid.path.paths)) )
            ### tempdir = tempdir[:-(len(tempsuf)-1)]
            kid.path.insert( cfgStr )
            _log.info( "Kid Paths %s"  % (str(kid.path.paths)) )

        cfgStr = turbogears.config.get("network", None, False, "wbcfg" )
        if cfgStr:
            WbConfigBase.addNetwork( cfgStr )

        cfgStr = turbogears.config.get("webbrickDirectory", None, False, "wbcfg" )
        if cfgStr:
            WbConfigSettings.ConfDir = cfgStr
            _log.info( "updated webbrick configuration directory %s" % (cfgStr) )

        userDir = turbogears.config.get("despatchConfig", None, False, "gateway" )
        sysDir = turbogears.config.get("despatchConfigSystem", None, False, "gateway" )
        self.eventloader = EventRouterLoader()
        # system files first.

        self.eventloader.loadFromDirectories( [sysDir, userDir] )

        #print WbConfigSettings_hga.ConfDir
        #print WbConfigSettings.ConfDir
        
        ###self.panel = PanelRenderer.PanelRenderer()

        self.local       = LocalData.LocalData()
        self.userinterface = UserInterface.UserInterface()

        self.nameCache = Webbrick.WebbrickNodeNameCache()
        self.wbsts = Webbrick.WebbrickStatusCache( self.nameCache )
        self.wbcmd = Webbrick.WebbrickCommand( self.nameCache )
        self.eventstate = EventState.EventState( )
        self.discover = DiscoverHandler()
        self.media = Media.Media()

        # need to handle discovery better
        self.wbcnf = WbCfgManagerForm( self.discover )

        # THIS IS FOR ARMOUR gateway config and discovery only 
        if ARMOUR_DEV:
            self.wbgwcnf = WbGwCfgManager()
        
        self.schedule = Schedule.Schedule()
        self.sendevent = SendEvent.SendEventLocal(self.eventloader.getEventRouter())
        self.wbproxy = Webbrick.WebbrickProxy()

        self.eventstate.start(self.eventloader.getEventRouter())
        
        self.nameCache.start(self.eventloader.getEventRouter())
        self.wbsts.start(self.eventloader.getEventRouter())
        self.discover.start(self.eventloader.getEventRouter())
        self.schedule.start()
        self.media.start(self.eventloader.getEventRouter())
        
        # event handlers last
        if self.eventloader:
            self.eventloader.start()
        
        if not self.eventloader.getEventRouter():
            print "EVENT DESPATCH TASK NOT LOADED/FAILED CONFIGURE"

        _log.info( "Sys Paths %s"  % (sys.path) )

        # Now publish the versions
        router = self.eventloader.getEventRouter()
        publish_versions(router)
        
        
        import kid
        _log.info( "Kid Paths %s"  % (str(kid.path.paths)) )
        _log.warning( "**** System Configured ****" )
コード例 #23
0
 def quiet(self):
     result = ClientProfiles.makeStandardResponse( cherrypy.request )
     return result