コード例 #1
0
ファイル: manager.py プロジェクト: mcayland/remuco
    def run(self):
        """Activate the manager.
        
        This method starts the player adapter, runs a main loop (GLib) and
        blocks until SIGINT or SIGTERM arrives or until stop() gets called. If
        this happens the player adapter gets stopped and this method returns.
        
        If `player_dbus_name` or `poll_fn` has been passed to __init__(), then
        the player adapter does not get started until the player is running
        (according to checks based on the DBus name or poll function). Also the
        adapter gets stopped automatically if the player is not running
        anymore. However, the manager keeps running, i.e. the player adapter
        may get started and stopped multiple times while this method is
        running.
        
        """
        if self.__observer is None:  # start pa directly
            ready = _start_pa(self.__pa)
        else:  # observer will start pa
            ready = True

        if ready and not self.__stopped:  # not stopped since creation
            log.info("start main loop")
            try:
                self.__ml.run()
            except Exception, e:
                log.exception("** BUG ** %s", e)
            else:
                log.info("main loop stopped")
コード例 #2
0
ファイル: manager.py プロジェクト: Sixthhokage2/remuco
 def run(self):
     """Activate the manager.
     
     This method starts the player adapter, runs a main loop (GLib) and
     blocks until SIGINT or SIGTERM arrives or until stop() gets called. If
     this happens the player adapter gets stopped and this method returns.
     
     If `player_dbus_name` or `poll_fn` has been passed to __init__(), then
     the player adapter does not get started until the player is running
     (according to checks based on the DBus name or poll function). Also the
     adapter gets stopped automatically if the player is not running
     anymore. However, the manager keeps running, i.e. the player adapter
     may get started and stopped multiple times while this method is
     running.
     
     """
     if self.__observer is None: # start pa directly
         ready = _start_pa(self.__pa)
     else: # observer will start pa
         ready = True
         
     if ready and not self.__stopped: # not stopped since creation 
         log.info("start main loop")
         try:
             self.__ml.run()
         except Exception, e:
             log.exception("** BUG ** %s", e)
         else:
             log.info("main loop stopped")
コード例 #3
0
ファイル: manager.py プロジェクト: cpatulea/remuco
 def run(self):
     """Activate the manager.
     
     This method starts the player adapter, runs a main loop (GLib) and
     blocks until SIGINT or SIGTERM arrives or until stop() gets called. If
     this happens the player adapter gets stopped and this method returns.
     
     @note: If the keyword 'player_dbus_name' has been set in __init__(),
         then the player adapter does not get started until an application
         owns the bus name given by 'player_dbus_name'. It automatically
         gets started whenever the DBus name has an owner (which means the
         adapter's player is running) and it gets stopped when it has no
         owner. Obvisously here the player adapter may get started and
         stopped repeatedly while this method is running.
     
     """
     if self.__observer is None: # start pa directly
         ready = _start_pa(self.__pa)
     else: # observer will start pa
         ready = True
         
     if ready and not self.__stopped: # not stopped since creation 
         
         log.info("start main loop")
         try:
             self.__ml.run()
         except Exception, e:
             log.exception("** BUG ** %s", e)
         log.info("main loop stopped")
コード例 #4
0
ファイル: manager.py プロジェクト: Sixthhokage2/remuco
def _stop_pa(pa):
    """Stop the given player adapter with error handling."""
    
    log.info("stop player adapter")
    try:
        pa.stop()
    except Exception, e:
        log.exception("** BUG ** %s", e)
コード例 #5
0
ファイル: manager.py プロジェクト: mcayland/remuco
def _stop_pa(pa):
    """Stop the given player adapter with error handling."""

    log.info("stop player adapter")
    try:
        pa.stop()
    except Exception, e:
        log.exception("** BUG ** %s", e)
コード例 #6
0
ファイル: manager.py プロジェクト: gkfabs/remuco
def _start_pa(pa):
    """Start the given player adapter with error handling."""
    
    log.info("start player adapter")
    try:
        pa.start()
    except StandardError as e:
        log.error("failed to start player adapter (%s)" % e)
        return False
    except Exception as e:
        log.exception("** BUG ** %s", e)
        return False
    else:
        log.info("player adapter started")
        return True
コード例 #7
0
ファイル: manager.py プロジェクト: Sixthhokage2/remuco
# =============================================================================
# start stop functions
# =============================================================================

def _start_pa(pa):
    """Start the given player adapter with error handling."""
    
    log.info("start player adapter")
    try:
        pa.start()
    except StandardError, e:
        log.error("failed to start player adapter (%s)" % e)
        return False
    except Exception, e:
        log.exception("** BUG ** %s", e)
        return False
    else:
        log.info("player adapter started")
        return True

def _stop_pa(pa):
    """Stop the given player adapter with error handling."""
    
    log.info("stop player adapter")
    try:
        pa.stop()
    except Exception, e:
        log.exception("** BUG ** %s", e)
    else:
        log.info("player adapter stopped")
コード例 #8
0
ファイル: manager.py プロジェクト: mcayland/remuco
# =============================================================================
# start stop functions
# =============================================================================


def _start_pa(pa):
    """Start the given player adapter with error handling."""

    log.info("start player adapter")
    try:
        pa.start()
    except StandardError, e:
        log.error("failed to start player adapter (%s)" % e)
        return False
    except Exception, e:
        log.exception("** BUG ** %s", e)
        return False
    else:
        log.info("player adapter started")
        return True


def _stop_pa(pa):
    """Stop the given player adapter with error handling."""

    log.info("stop player adapter")
    try:
        pa.stop()
    except Exception, e:
        log.exception("** BUG ** %s", e)
    else:
コード例 #9
0
ファイル: serial.py プロジェクト: gkfabs/remuco
def pack(serializable):

    fmt = serializable.get_fmt()
    
    data = serializable.get_data()
    
    if len(fmt) != len(data):
        log.error("** BUG ** format string and data differ in length")
        return None
        
    #log.debug("data to pack: %s" % str(data))

    bin = Bin()
    
    try:

        for i in range(0,len(fmt)):
            
            type = fmt[i]
            bin.write_byte(type)
            
            if type == TYPE_Y:
                
                bin.write_byte(data[i])
                
            elif type == TYPE_B:
                
                bin.write_boolean(data[i])
        
            elif type == TYPE_N:
                
                bin.write_short(data[i])
                
            elif type == TYPE_I:
                
                bin.write_int(data[i])
                
            elif type == TYPE_L:
                
                bin.write_long(data[i])
                
            elif type == TYPE_S:
                
                bin.write_string(data[i])
                
            elif type == TYPE_AB:
                
                bin.write_array_boolean(data[i])
                
            elif type == TYPE_AY:
                
                bin.write_array_byte(data[i])
                
            elif type == TYPE_AN:
                
                bin.write_array_short(data[i])

            elif type == TYPE_AI:
                
                bin.write_array_int(data[i])

            elif type == TYPE_AL:
                
                bin.write_array_long(data[i])

            elif type == TYPE_AS:
                
                bin.write_array_string(data[i])

            else:
                log.error("** BUG ** unknown type (%d) in format string" % type)
                return None
        
    except struct.error as e:
        
        log.exception("** BUG ** %s" % e)
        
        return None
    
    return bin.get_buff()
コード例 #10
0
ファイル: serial.py プロジェクト: mcayland/remuco
def pack(serializable):

    fmt = serializable.get_fmt()

    data = serializable.get_data()

    if len(fmt) != len(data):
        log.error("** BUG ** format string and data differ in length")
        return None

    #log.debug("data to pack: %s" % str(data))

    bin = Bin()

    try:

        for i in range(0, len(fmt)):

            type = fmt[i]

            bin.write_byte(type)

            if type == TYPE_Y:

                bin.write_byte(data[i])

            elif type == TYPE_B:

                bin.write_boolean(data[i])

            elif type == TYPE_N:

                bin.write_short(data[i])

            elif type == TYPE_I:

                bin.write_int(data[i])

            elif type == TYPE_L:

                bin.write_long(data[i])

            elif type == TYPE_S:

                bin.write_string(data[i])

            elif type == TYPE_AB:

                bin.write_array_boolean(data[i])

            elif type == TYPE_AY:

                bin.write_array_byte(data[i])

            elif type == TYPE_AN:

                bin.write_array_short(data[i])

            elif type == TYPE_AI:

                bin.write_array_int(data[i])

            elif type == TYPE_AL:

                bin.write_array_long(data[i])

            elif type == TYPE_AS:

                bin.write_array_string(data[i])

            else:
                log.error("** BUG ** unknown type (%d) in format string" %
                          type)
                return None

    except struct.error, e:

        log.exception("** BUG ** %s" % e)

        return None