def found_action_upload(remote, record = None, line=None): from openproximity.rpc.server import OpenProximityService uploader = OpenProximityService.getUploader() if uploader is None: line.content+=" no uploaders, can't handle" line.save() return True logger.info("found uploader") camps = getMatchingCampaigns( remote, enabled=True, record=record, classes=[MarketingCampaign,] ) if len(camps)==0: line.content+=" no matching campaings, not handling" line.save() logger.info("no campaigns") return True channel = None files=list() name=None service='opp' use_same = False for camp in camps: files.extend( list(get_files_from_campaign(camp, record)) ) if camp.dongle_name: name = camp.dongle_name service = camp.get_service_display() if camp.fixed_channel and camp.fixed_channel > -1: channel = camp.fixed_channel if camp.upload_on_discovered: use_same = True sdp = RemoteBluetoothDeviceSDP.objects.filter(remote__pk=record.remote.pk) if sdp.count() > 0: channel = sdp.order_by("-time")[0].channel line.content += "using previous resolved channel %i" % channel logger.info("going to upload %s files" % len(files)) if len(files) > 0: OpenProximityService.addPending(record.remote.address, uploader) do_upload(uploader, files, record.remote.address, service, name, channel=channel, dongle=dongle if use_same else None) line.content+=" uploading files" else: line.content+=" no files to upload" line.save()
def found_action(address, record, dongle): line = LogLine() line.content = "Found action for: %s" % address try: for plugin in pluginsystem.get_plugins("found_action"): logger.info("found action trying with %s" % plugin.name) service = plugin.rpc["found_action"](record=record, dongle=dongle) if service: logger.info("plugin has handled") line.content += " %s is handling" % getattr(plugin, "name", "plugin") line.save() OpenProximityService.addPending(address, service) return True except Exception, err: logger.error("plugin do_action") logger.exception(err)
def found_action(address, record, dongle): line = LogLine() line.content="Found action for: %s" % address try: for plugin in pluginsystem.get_plugins('found_action'): logger.info("found action trying with %s" % plugin.name) service = plugin.rpc['found_action'](record=record, dongle=dongle) if service: logger.info("plugin has handled") line.content+=" %s is handling" % getattr(plugin, 'name', 'plugin') line.save() OpenProximityService.addPending(address, service) return True except Exception, err: logger.error("plugin do_action") logger.exception(err)