示例#1
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"
示例#2
0
def idAnalogThreshold65(hilo,valmap,trgnam,elem):
    # returns "{H|L};<threshold>;{A|D}<chn>;<setpt>;<action>;<dwelltime>;<udptype>;<remotechan>
    trg = elem.getElementsByTagName(trgnam)[0]
    val = trg.getAttribute("Val") or trg.getAttribute("Lo") or trg.getAttribute("Hi") 
    Trace("trg %s, val %s"%(getElemXml(trg),val), "WebBrickConfig.idAnalogThreshold")
    return hilo+";"+valmap(val)+";"+trigger65(trgnam,None,elem)
示例#3
0
 def mkCmd(cn,ov,transform,e):
     Trace("Generate command %s for element %s"%(cn,getElemXml(e)), "WebBrickConfig.WebBrickConfig")
     try:
         val = (ov and override.get(ov)) or transform(e)
     except Exception, exc:
         raise WebBrickConfigException(command=cn, element=getElemXml(e), cause=str(exc))