示例#1
0
    def _wscb_get(self, channel, message):
        """ Callback for the get operation

        :param channel: The name of the channel containing the get request
        :type channel: str
        :param message: The message received over the channel
        :type message: dict -- not used
        """

        # Array version of variable
        variable_arr = self._get_variable_from_channel(channel)
        # Joined string version of variable
        variable = ".".join(variable_arr)

        # Dispatch for specific elements
        # Medias are not stored internally
        if variable == 'medias':
            value = MediaManager.get_all()
        elif variable in [
                'medias.audio', 'medias.video', 'medias.image',
                'medias.scenario'
        ]:
            value = MediaManager.get(variable.split('.')[1])
        else:
            # Internal value, handled by us
            value = self._get_struct(variable_arr, self._store)

        logging.debug("got get request for value %s, sending back value %s" %
                      (variable, value))
        return_channel = "storage.event.%s" % variable

        self._ws.send(return_channel, {'value': value})
示例#2
0
    def _wscb_get(self, channel, message):
        """ Callback for the get operation

        :param channel: The name of the channel containing the get request
        :type channel: str
        :param message: The message received over the channel
        :type message: dict -- not used
        """

        # Array version of variable
        variable_arr = self._get_variable_from_channel(channel)
        # Joined string version of variable
        variable = ".".join(variable_arr)

        # Dispatch for specific elements
        # Medias are not stored internally
        if variable == 'medias':
            value = MediaManager.get_all()
        elif variable in ['medias.audio', 'medias.video', 'medias.image', 'medias.scenario']:
            value = MediaManager.get(variable.split('.')[1])
        else:
            # Internal value, handled by us
            value = self._get_struct(variable_arr, self._store)

        logging.debug("got get request for value %s, sending back value %s" % (variable, value))
        return_channel = "storage.event.%s" % variable

        self._ws.send(return_channel, { 'value': value })
示例#3
0
    def _wscb_start(self, channel, message):
        # Message types :
        # play
        media = MediaManager.get_media_dict('image', message['media'])

        logging.debug("Playing image %s" % media['path'])

        self.backend.play(media['path'])
        self.send_status('start', { "type" : "image",
                                    "media": message['media'] })
        self.send_event('start', { "media": self.backend.image })
示例#4
0
    def _wscb_start(self, channel, message):
        media = MediaManager.get_media_dict('video', message['media'])

        logging.debug("playing media %s" % media['path'])
        self.backend.play(media['path'])
        self.send_status('start')
示例#5
0
 def _autostart_scenarios(self):
     """ Advertises scenarios that have to run at start
     """
     for sc in json.loads(MediaManager.get('scenario')):
         if 'autostart' in sc and sc['autostart'] == True:
             self._start_scenario(sc)
示例#6
0
 def get(self, target):
     self.write(MediaManager.get(target))
示例#7
0
 def get(self, target):
     self.write(MediaManager.get(target))