Exemple #1
0
 def success_cb(cmd, data, args):
     log.debug('entering zero_success_cb')
     mode = cmd[:2]
     offset = int(cmd[2:4])
     self._supported_pids += decode_pids_from_bitstring(data, mode, offset)
     next = '%d' % (offset + 20)
     if mode + next in self._supported_pids:
         self._send_command(mode + next, success_cb, error_cb)
     else:
         if len(modes):
             mode = modes.pop()
             self._send_command(mode + '00', success_cb, error_cb)
         else:
             log.info('supported pids: %s\n' % self._supported_pids)
             if not self._connected:
                 self._connected = True
                 self.emit('connected', True)
             self.emit('supported-pids-changed')
Exemple #2
0
 def _deactivate_plugin(self, plugin):
     
     instance = self._plugin_instance_from_string(plugin)
     istr = str(instance)
     
     if instance.action_group:
         self.app.ui.remove_action_group(instance.action_group)
     if instance.merge_id:
         self.app.ui.remove_ui(instance.merge_id)
     if hasattr(instance, 'unload'):
         instance.unload()
     del instance
         
     for item in self._active_plugins:
         string, i = item
         if string ==  plugin:
             self._active_plugins.remove(item)
                 
     log.info('Plugin deactivated: %s' % plugin)
     log.debug('Plugin deactivated: %s' % istr)
Exemple #3
0
    def _parse_result(self, data):
        log.debug('entering ELMDevice._parse_result: %s' % data)
        error = False
        success = False
        res = None
        msg = None
        
        cmd = self._sent_command
        err_cb = self._err_cb
        ret_cb = self._ret_cb
        args = self._cb_args
        
        if self._sent_command:
            if data[0] == '>':
                log.debug('command sent, received >')
                error = True
                
            elif data[0] == '?':
                log.debug('command sent, received ?')
                error = True
                msg = '?'

            elif 'ERROR' in data:
                log.info('received ERROR')
                error = True
                msg = data
                
            elif 'SEARCHING' in data:
                log.info('received SEARCHING: resending command')
                self._send_command(cmd, ret_cb, err_cb, args)

            elif 'BUS INIT' in data:
                log.info('received BUS INIT: resending command')
                self._send_command(cmd, ret_cb, err_cb, args)
                
            elif 'UNABLE TO CONNECT' in data:
                log.debug('received UNABLE TO CONNECT')
                error = True
                msg = 'UNABLE TO CONNECT'

            elif 'NO DATA' in data:
                log.debug('received NO DATA')
                error = True
                msg = 'NO DATA'
                
            else:
                res = data
                success = True
                
            if self._cleanup_command:
                self._err_cb = None
                self._ret_cb = None
                self._sent_command = None
                self._cb_args = None
                
            if error:
                err_cb(cmd, msg, args)
                
            if success:
                ret_cb(cmd, data, args)
                
        else:
            # no command sent
            # are we interested anyway?
            if '>' in data:
                log.debug('received >')
            else:
                log.debug('no command sent, received %s' % data)
Exemple #4
0
        else:
            log.error('%s does not seem to be a valid Plugin' % instance)
            instance = None
            return None

        try:
            if instance.ui_info:
                instance.merge_id = self.app.ui.add_ui_from_string(instance.ui_info)
                self.app.ui.insert_action_group(instance.action_group, 0)
        except gobject.GError, msg:
                log.error('building menus failed: %s' % msg)
        
        if hasattr(instance, 'load'):                    
            instance.load()

        log.info('Plugin activated: %s' % plugin)
        log.debug(instance)
        return instance
            
            
    def _deactivate_plugin(self, plugin):
        
        instance = self._plugin_instance_from_string(plugin)
        istr = str(instance)
        
        if instance.action_group:
            self.app.ui.remove_action_group(instance.action_group)
        if instance.merge_id:
            self.app.ui.remove_ui(instance.merge_id)
        if hasattr(instance, 'unload'):
            instance.unload()