def __init__(self): self.frequencies = {} self.bands = 0 self.scan_period_cold = config.get_parameter("scan_period_cold", 10) self.scan_reschedule_delay = config.get_parameter("scan_reschedule_delay", 2) self.scan_period_randomness = config.get_parameter("scan_period_randomness", 0) self.min_scan_interval = config.get_parameter("min_scan_interval", 1)
def __init__(self): self.frequencies = {} self.bands = 0 self.scan_period_cold = config.get_parameter('scan_period_cold', 10) self.scan_reschedule_delay = config.get_parameter('scan_reschedule_delay', 2) self.scan_period_randomness = config.get_parameter('scan_period_randomness', 0) self.min_scan_interval = config.get_parameter('min_scan_interval', 1)
def __init__(self): self.failed_scan_delay = config.get_parameter('failed_scan_delay', 1) self.scan_results = {} self.frequencies = FrequencyList() self.num_scan_frequencies = config.get_parameter('num_scan_frequencies', 4) self.scheduled_scan = {} self.bss_list = BssList(self.frequencies) self.new_scan_data = event.Event()
def __init__(self): self.failed_scan_delay = config.get_parameter("failed_scan_delay", 1) self.scan_results = {} self.frequencies = FrequencyList() self.num_scan_frequencies = config.get_parameter("num_scan_frequencies", 4) self.scheduled_scan = {} self.bss_list = BssList(self.frequencies) self.new_scan_data = event.Event()
def __init__(self, iface, tableid, cfgname): self.iface = iface self.cfgname = cfgname self.prettyname = config.get_interface_parameter(self.cfgname, 'name', self.cfgname) self.active = True self.priority = config.get_interface_parameter(self.cfgname, 'priority', 0) src_rule_setter = DhcpSourceRuleSetter(iface, tableid, tableid) self.tableid = str(tableid) base_station = config.get_parameter('base_station') ping_port = config.get_parameter('ping_port') self.ping_tester = ping_tester.PingTester(iface, 20, (base_station, ping_port), src_rule_setter.state_pub)
def __init__(self): self.interfaces = {} self.update_event = event.Event() self.update_interval = 1 self.radio_manager = radio_manager.RadioManager() self.inactive_penalty = config.get_parameter('inactive_penalty', 50) self.forced_interface = "" self.tunnel_interface = config.get_parameter('tunnel_interface', "") self.use_tunnel = True self.active_interfaces = [] self.basestation = config.get_parameter('base_station') # print "Resolving basestation IP. (Blocking operation.)" # self.basestation_ip = socket.gethostbyname(config.get_parameter('base_station')) # Add rules to guarantee that local routes go to the main table. # self.local_net_rule = ip_rule.IpRule(RULEID.LOCAL) # for subnet in config.get_parameter('local_networks'): # self.local_net_rule.add('to', subnet, 'lookup', 'main') self.local_net_rules = [] for (i, subnet) in enumerate(config.get_parameter('local_networks')): self.local_net_rules.append(ip_rule.IpRule(RULEID.LOCAL + i)) self.local_net_rules[i].add('to', subnet, 'lookup', 'main') # Add a rule to send through the vpn. if self.tunnel_interface: self.vpn_rule = ip_rule.IpRule(RULEID.DEFAULT) # Use LINK here because netlink_monitor's parsing rules don't # currently work on vpn interfaces. system.system('ip', 'route', 'flush', 'table', str(RULEID.DEFAULT)) netlink_monitor.get_state_publisher( self.tunnel_interface, IFSTATE.LINK).subscribe(self._refresh_default_route) # Create all the interfaces. interface_names = config.get_parameter('interfaces').keys() ifaceid = RULEID.FIRST_IFACE for iface in interface_names: try: new_iface = self.interfaces[iface] = interface.construct( iface, ifaceid) new_iface.score = InterfaceSelector.TERRIBLE_INTERFACE new_iface.prescore = InterfaceSelector.TERRIBLE_INTERFACE ifaceid += 1 except interface.NoType: print >> sys.stderr, "Interface %s has no type." % iface sys.exit(1) except interface.UnknownType, e: print >> sys.stderr, "Interface %s has unknown type %s." % ( iface, e) sys.exit(1) except:
def __init__(self): self.interfaces = {} self.update_event = event.Event() self.update_interval = 1 self.radio_manager = radio_manager.RadioManager() self.inactive_penalty = config.get_parameter('inactive_penalty', 50) self.forced_interface = "" self.tunnel_interface = config.get_parameter('tunnel_interface', "") self.use_tunnel = True self.active_interfaces = [] self.basestation = config.get_parameter('base_station') # print "Resolving basestation IP. (Blocking operation.)" # self.basestation_ip = socket.gethostbyname(config.get_parameter('base_station')) # Add rules to guarantee that local routes go to the main table. # self.local_net_rule = ip_rule.IpRule(RULEID.LOCAL) # for subnet in config.get_parameter('local_networks'): # self.local_net_rule.add('to', subnet, 'lookup', 'main') self.local_net_rules = [] for (i, subnet) in enumerate(config.get_parameter('local_networks')): self.local_net_rules.append(ip_rule.IpRule(RULEID.LOCAL+i)) self.local_net_rules[i].add('to', subnet, 'lookup', 'main') # Add a rule to send through the vpn. if self.tunnel_interface: self.vpn_rule = ip_rule.IpRule(RULEID.DEFAULT) # Use LINK here because netlink_monitor's parsing rules don't # currently work on vpn interfaces. system.system('ip', 'route', 'flush', 'table', str(RULEID.DEFAULT)) netlink_monitor.get_state_publisher(self.tunnel_interface, IFSTATE.LINK).subscribe(self._refresh_default_route) # Create all the interfaces. interface_names = config.get_parameter('interfaces').keys() ifaceid = RULEID.FIRST_IFACE for iface in interface_names: try: new_iface = self.interfaces[iface] = interface.construct(iface, ifaceid) new_iface.score = InterfaceSelector.TERRIBLE_INTERFACE new_iface.prescore = InterfaceSelector.TERRIBLE_INTERFACE ifaceid += 1 except interface.NoType: print >> sys.stderr, "Interface %s has no type."%iface sys.exit(1) except interface.UnknownType, e: print >> sys.stderr, "Interface %s has unknown type %s."%(iface, e) sys.exit(1) except:
def __init__(self, iface, tableid, cfgname): self.iface = iface self.cfgname = cfgname self.prettyname = config.get_interface_parameter( self.cfgname, 'name', self.cfgname) self.active = True self.priority = config.get_interface_parameter(self.cfgname, 'priority', 0) src_rule_setter = DhcpSourceRuleSetter(iface, tableid, tableid) self.tableid = str(tableid) base_station = config.get_parameter('base_station') ping_port = config.get_parameter('ping_port') self.ping_tester = ping_tester.PingTester(iface, 20, (base_station, ping_port), src_rule_setter.state_pub)
def __init__(self, iface): self.iface = iface self.ping_timeout = config.get_parameter("ping_timeout", 4) self.is_verified = StatePublisher(False) self.has_address = False iface.ping_tester.update_event.subscribe_repeating(self._update) netlink_monitor.get_state_publisher(iface.iface, IFSTATE.ADDR).subscribe(self._has_address_cb, iface)
def __init__(self, iface): self.iface = iface self.ping_timeout = config.get_parameter('ping_timeout', 4) self.is_verified = StatePublisher(False) self.has_address = False iface.ping_tester.update_event.subscribe_repeating(self._update) netlink_monitor.get_state_publisher(iface.iface, IFSTATE.ADDR).subscribe( self._has_address_cb, iface)
def __init__(self): self.scan_manager = ScanManager() self.best_active = None self.iface_associations = {} self.initial_inhibit_end = time.time() + config.get_parameter('initial_assoc_inhibit', 5) self.bss_expiry_time = config.get_parameter('bss_expiry_time', 5) self.activate_hysteresis = config.get_parameter('activate_hysteresis', 5) self.max_hot_frequencies = config.get_parameter('max_hot_frequencies', 3) self.scan_period_warm = config.get_parameter('scan_period_warm', 10) self.scan_period_hot = config.get_parameter('scan_period_hot', 4) self.reassociate_hysteresis = config.get_parameter('reassociate_hysteresis', 5) self.same_bss_penalty = config.get_parameter('same_bss_penalty', 20) self.interfaces = set() self.set_mode() # Initializes some variables self.scan_manager.new_scan_data.subscribe_repeating(self._new_scan_data) self.hot_bss_expiry_time = config.get_parameter('hot_bss_expiry_time', 5) self.warm_bss_expiry_time = config.get_parameter('warm_bss_expiry_time', 3 * self.scan_period_warm)
def __init__(self, iface, rate, pingtarget, state_pub): self.update_event = Event() reactor.addSystemEventTrigger("before", "shutdown", self._shutdown) self.udp_monitor = udpmoncli.MonitorClient( [config.get_parameter("ping_max_latency", 0.2)], pingtarget, rate, 32, True ) CompositeStatePublisher( lambda (addr, ready): None if not ready else addr, [netlink_monitor.get_state_publisher(iface, IFSTATE.ADDR), state_pub], ).subscribe(self._addr_cb)
def __init__(self): self.scan_manager = ScanManager() self.best_active = None self.iface_associations = {} self.initial_inhibit_end = time.time() + config.get_parameter("initial_assoc_inhibit", 5) self.bss_expiry_time = config.get_parameter("bss_expiry_time", 5) self.activate_hysteresis = config.get_parameter("activate_hysteresis", 5) self.max_hot_frequencies = config.get_parameter("max_hot_frequencies", 3) self.scan_period_warm = config.get_parameter("scan_period_warm", 10) self.scan_period_hot = config.get_parameter("scan_period_hot", 4) self.reassociate_hysteresis = config.get_parameter("reassociate_hysteresis", 5) self.same_bss_penalty = config.get_parameter("same_bss_penalty", 20) self.interfaces = set() self.set_mode() # Initializes some variables self.scan_manager.new_scan_data.subscribe_repeating(self._new_scan_data) self.hot_bss_expiry_time = config.get_parameter("hot_bss_expiry_time", 5) self.warm_bss_expiry_time = config.get_parameter("warm_bss_expiry_time", 3 * self.scan_period_warm)
def set_mode(self, ssid = "", bssid = "", sel_interface = "", use_tunnel = True, band = 3, scan_only = False): print >> sys.stderr, "Dynamic reconfiguration ssid: %s bssid: %s iface: %s tun: %s band: %s scan_only: %s"%(ssid, bssid, sel_interface, use_tunnel, band, scan_only) self.goodness_weight = config.get_parameter('ping_weighting', 0.5) self.radio_manager.set_mode(ssid, bssid, band, scan_only, sel_interface) self.forced_interface = sel_interface self.use_tunnel = use_tunnel if self.tunnel_interface: if use_tunnel: self.vpn_rule.set('lookup', str(RULEID.DEFAULT)) else: self.vpn_rule.set()
def __init__(self, iface): self.iface = iface self.socket = None self.link_addr_state = monitor.get_state_publisher(self.iface, IFSTATE.LINK_ADDR) self.error_event = event.Event() self.binding_publisher = state_publisher.StatePublisher(None) self.error_timeout = 5 self.exp_backoff_min = 0.2 self.exp_backoff_max = 0.5 self.exp_backoff_timeout = config.get_parameter('dhcp_timeout', 2) self.leases = {}
def __init__(self, iface, rate, pingtarget, state_pub): self.update_event = Event() reactor.addSystemEventTrigger('before', 'shutdown', self._shutdown) self.udp_monitor = udpmoncli.MonitorClient( [config.get_parameter('ping_max_latency', 0.2)], pingtarget, rate, 32, True) CompositeStatePublisher( lambda (addr, ready): None if not ready else addr, [ netlink_monitor.get_state_publisher(iface, IFSTATE.ADDR), state_pub, ]).subscribe(self._addr_cb)
def _update(self, status): # print "PingMonitor._update" if status: (bins, latency1, latency2) = status # print "PingMonitor", bins, self.restart_time - time.time() if status and bins[0]: self.restart_time = time.time() + self.ping_timeout self.is_verified.set(True) elif self.has_address and self.restart_time < time.time(): if not config.get_parameter("disable_ping_timeout"): print "PingMonitor restarting", self.iface.iface self.has_address = False self.iface.interface_upper.restart() else: print "PingMonitor restart was disabled by disable_ping_timeout", self.iface.iface self._set_timeout()
def _update(self, status): #print "PingMonitor._update" if status: (bins, latency1, latency2) = status #print "PingMonitor", bins, self.restart_time - time.time() if status and bins[0]: self.restart_time = time.time() + self.ping_timeout self.is_verified.set(True) elif self.has_address and self.restart_time < time.time(): if not config.get_parameter('disable_ping_timeout'): print "PingMonitor restarting", self.iface.iface self.has_address = False self.iface.interface_upper.restart() else: print "PingMonitor restart was disabled by disable_ping_timeout", self.iface.iface self._set_timeout()
def set_mode(self, ssid="", bssid="", sel_interface="", use_tunnel=True, band=3, scan_only=False): print >> sys.stderr, "Dynamic reconfiguration ssid: %s bssid: %s iface: %s tun: %s band: %s scan_only: %s" % ( ssid, bssid, sel_interface, use_tunnel, band, scan_only) self.goodness_weight = config.get_parameter('ping_weighting', 0.5) self.radio_manager.set_mode(ssid, bssid, band, scan_only, sel_interface) self.forced_interface = sel_interface self.use_tunnel = use_tunnel if self.tunnel_interface: if use_tunnel: self.vpn_rule.set('lookup', str(RULEID.DEFAULT)) else: self.vpn_rule.set()
# -*- coding:utf-8 -*- from config import get_parameter from PIL import Image, ImageEnhance from glob import glob from tqdm import tqdm import random import numpy as np import pandas as pd import os import cv2 from skimage.util import random_noise from skimage import exposure parameter = get_parameter() data_path = parameter['data_set'] list_path = parameter['list'] data_aug_path = parameter['data_aug'] # 加高斯噪声 def addNoise(img): return random_noise(img, mode='gaussian', seed=13, clip=True) * 255 # 调节亮度 def light_change(img): scaler = random.uniform(0.5, 1.5) img = exposure.adjust_gamma(img, scaler)
def print_header(screen, columns, config): screen.addstr(config.get_parameter('title') + ' ' + config.get_parameter('version') + '\n') screen.addstr(config.get_parameter('horizontal_line') * columns + '\n') screen.addstr(config.get_parameter('horizontal_line') * columns)