Beispiel #1
0
def get_dongles(dongles):
    out = list()
    
    for address in dongles:
        logger.debug(address)
        try:
            if not is_known_dongle(address, UploaderBluetoothDongle) and \
                                                            isAIRcable(address):
                logger.info('not known uploader %s' % address)
                setting = settings.GETUPLOADERDONGLE(address)
                if not setting:
                   logger.info('no settings for uploaders')
                   continue

                logger.info('default settings where found')
                logger.debug(setting)
                max_conn = setting.get('value', 1)
                enabled = setting.get('enable', True)
                name = setting.get('name', _("Autodiscovered Bluetooth dongle"))

                UploaderBluetoothDongle.objects.get_or_create(address=address, 
                    defaults={
                        'name': name,
                        'enabled': enabled,
                        'max_conn': max_conn
                    }
                )
            dongle = UploaderBluetoothDongle.objects.get(address=address, enabled=True)
            out.append( (address, dongle.max_conn, dongle.name) )
        except Exception, err:
            logger.exception(err)
def get_dongles(dongles):
    out = list()
    
    for address in dongles:
        print address
        try:
            if not is_known_dongle(address, UploaderBluetoothDongle) and \
                                                            isAIRcable(address):
                logger.info('not known uploader %s' % address)
                settings = SET.getSettingsByAddress(address)
                if not 'uploader' in settings:
                   logger.info('no settings for uploaders')
                   continue
                    
                logger.info('default settings where found')
                logger.debug(settings['uploader'])
                max_conn = settings['uploader'].get('max_conn', 1)
                enabled = settings['uploader'].get('enable', True)
                name = settings['uploader'].get('name', _("Autodiscovered Bluetooth dongle"))
                    
                UploaderBluetoothDongle.objects.get_or_create(address=address, 
                    defaults={
                        'name': name,
                        'enabled': enabled,
                        'max_conn': max_conn
                    }
                )
            dongle = UploaderBluetoothDongle.objects.get(address=address, enabled=True)
            out.append( (address, dongle.max_conn, dongle.name) )
        except Exception, err:
            logger.exception(err)
def get_dongles(dongles):
    out = list()

    for address in dongles:
        logger.debug(address)
        try:
            if not is_known_dongle(address, UploaderBluetoothDongle) and isAIRcable(address):
                logger.info("not known uploader %s" % address)
                setting = settings.GETUPLOADERDONGLE(address)
                if not setting:
                    logger.info("no settings for uploaders")
                    continue

                logger.info("default settings where found")
                logger.debug(setting)
                max_conn = setting.get("value", 1)
                enabled = setting.get("enable", True)
                name = setting.get("name", _("Autodiscovered Bluetooth dongle"))

                UploaderBluetoothDongle.objects.get_or_create(
                    address=address, defaults={"name": name, "enabled": enabled, "max_conn": max_conn}
                )
            dongle = UploaderBluetoothDongle.objects.get(address=address, enabled=True)
            out.append((address, dongle.max_conn, dongle.name))
        except Exception, err:
            logger.exception(err)
Beispiel #4
0
def get_dongles(dongles):
    def create_new_discovered_dongle(address, settings):
        logger.info("going to setup as scanner")
        priority = settings.get('value', 1)
        enabled = settings.get('enable', True)
        name = settings.get('name', _("Auto Discovered Dongle"))
        obj, created = ScannerBluetoothDongle.objects.get_or_create(
            address=address,
            defaults={
                'priority': priority,
                'enabled': enabled,
                'name': name
            })
        logger.debug("%s %s[%s]" % (address, name, priority))

    def internal_get_dongles(address):
        dongle = ScannerBluetoothDongle.objects.get(address=address)
        logger.info("%s is a scanner dongle" % address)

        if dongle.enabled:
            yield (address, dongle.priority, dongle.name)

        if dongle.remote_dongles.count() > 0:
            logger.info("We have remote dongles available")
            for remote in dongle.remote_dongles.all():
                if remote.enabled:
                    yield (remote.address, remote.priority, dongle.address)

    out = list()

    for address in dongles:
        try:
            if not is_known_dongle(address, ScannerBluetoothDongle):
                logger.info("dongle not known yet %s" % address)
                setting = settings.GETSCANNERDONGLE(address)
                if setting:
                    create_new_discovered_dongle(address, setting)
            out.extend(internal_get_dongles(address))
        except Exception, err:
            logger.exception(err)
Beispiel #5
0
def get_dongles(dongles):
    def create_new_discovered_dongle(address, settings):
        logger.info("going to setup as scanner")
        priority = settings['scanner'].get('priority', 1)
        enabled = settings['scanner'].get('enable', True)
        name = settings['scanner'].get('name', _("Auto Discovered Dongle"))
        obj, created = ScannerBluetoothDongle.objects.get_or_create(
            address=address, 
            defaults={
                'priority': priority,
                'enabled': enabled,
                'name': name
            })
        logger.debug("%s %s[%s]" % (address, name, priority))

    def internal_get_dongles(address):
        dongle = ScannerBluetoothDongle.objects.get(address=address)
        logger.info("%s is a scanner dongle" % address)
	    
        if dongle.enabled:
            yield (address, dongle.priority, dongle.name)
	    	
        if dongle.remote_dongles.count() > 0:
            logger.info("We have remote dongles available")
            for remote in dongle.remote_dongles.all():
                if remote.enabled:
                    yield ( remote.address, remote.priority, dongle.address )

    out = list()
    
    for address in dongles:
        try:
            if not is_known_dongle(address, ScannerBluetoothDongle):
                logger.info("dongle not known yet %s" % address)
                settings = SET.getSettingsByAddress(address)
                if 'scanner' in settings:
                    create_new_discovered_dongle(address, settings)
            out.extend(internal_get_dongles(address))
        except Exception, err:
            logger.exception(err)