def __getitem__(self, idx):
     lr, hr, filename = self._load_file(idx)
     lr, hr = utils.get_patch_tot(self.phase, self.args, lr, hr)
     lr, hr = utils.set_channel([lr, hr], n_channel=self.args.n_colors)
     lr_t, hr_t = utils.np_to_tensor([lr, hr],
                                     rgb_range=self.args.rgb_range)
     return lr_t, hr_t, filename
示例#2
0
    def handle(self):
        if self.request['action'] == 'startJamming':
            jamming_channel = self.request['jammingChannel']
            logger.debug("Jamming channel %d" % (jamming_channel))
            utils.set_channel(jamming_channel)
            stations = [
                sta for sta in get_station_dump()['band2g'] if 'IP' in sta
            ]
            if len(stations) == 0:
                logger.debug("Not stations, can not jam.")
            else:
                client_ip = stations[0]['IP']
                subprocess.Popen('iperf -c %s -u -b 72M -t 1000000' %
                                 (client_ip),
                                 shell=True)
        elif self.request['action'] == 'stopJamming':
            logger.debug("Stop Jamming")
            try:
                subprocess.check_call('pgrep -f "iperf" | xargs kill -9',
                                      shell=True)
            except:
                pass

        self.send_reply()