def channel_list_from_config(self, rc): channels = [] for ssect in rc.sections(): if ssect == MAINSECTION: continue ch = channel() ch.freq = engnum(rc.get(ssect, "freq")) ch.bw = engnum(rc.get(ssect, "bw")) ch.pipe = cfg_safe(rc.get, ssect, 'pipe', None) channels.append(ch) return channels
def on_freq_change(widget, event): """ Handle edit in the Frequency textbox """ global frequency if not is_enter(event): return False newf = libutil.safe_cast(libutil.engnum(tb_freq.get_text()), int) if newf: cl.set_frequency(newf) frequency = newf return True
def xlater_edit(cell, row, new_value, field): """ Row in listview changed """ cl.acquire_xlaters() newcast = libutil.safe_cast(libutil.engnum(new_value), type(model[row][field])) if not newcast: showerror("Value was not understood") return # handle frequency/offset consistency if field == 7: model[row][1] = newcast - frequency elif field == 1: model[row][7] = frequency + newcast model[row][field] = newcast commit_xlater(row) cl.release_xlaters()
def __init__(self): confdir = os.path.join(os.path.expanduser('~'), ".kukuruku/scanner/") # Read global config rc = configparser.ConfigParser() cfpath = os.path.join(confdir, "main.conf") rc.read(cfpath) self.bufsize = cfg_safe(rc.getint, MAINSECTION, 'bufsize', 2048000, cfpath) self.rate = cfg_safe(rc.getint, MAINSECTION, 'rate', 2048000, cfpath) self.interval = cfg_safe(rc.getint, MAINSECTION, 'interval', 5, cfpath) self.skip = cfg_safe(rc.getint, MAINSECTION, 'skip', 3, cfpath) self.fftw = cfg_safe(rc.getint, MAINSECTION, 'fftw', 2048, cfpath) self.fftskip = cfg_safe(rc.getint, MAINSECTION, 'fftskip', 32, cfpath) self.overlap = cfg_safe(rc.getfloat, MAINSECTION, 'overlap', 0.2, cfpath) self.nonce = cfg_safe(rc.get, MAINSECTION, 'nonce', "abcdef", cfpath) self.floor = cfg_safe(rc.getfloat, MAINSECTION, 'floor', 0.4, cfpath) self.sql = cfg_safe(rc.getfloat, MAINSECTION, 'sql', 0.5, cfpath) self.filtermargin = cfg_safe(rc.getfloat, MAINSECTION, 'filtermargin', 1.5, cfpath) self.transition = cfg_safe(rc.getfloat, MAINSECTION, 'transition', 0.2, cfpath) self.minw = cfg_safe(rc.get, MAINSECTION, 'minw', 10000, cfpath) self.maxw = cfg_safe(rc.get, MAINSECTION, 'maxw', 200000, cfpath) self.messgain = cfg_safe(rc.getint, MAINSECTION, 'messgain', 1, cfpath) self.mingain = cfg_safe(rc.getint, MAINSECTION, 'mingain', 10, cfpath) self.maxgain = cfg_safe(rc.getint, MAINSECTION, 'maxgain', 49, cfpath) self.gain = cfg_safe(rc.get, MAINSECTION, 'gain', "0,30,30,30", cfpath) self.stickactivity = cfg_safe(rc.getboolean, MAINSECTION, 'stickactivity', False, cfpath) self.stick = cfg_safe(rc.getint, MAINSECTION, 'stick', 10, cfpath) self.silencegap = cfg_safe(rc.getint, MAINSECTION, 'silencegap', 5, cfpath) self.dumpspectrum = cfg_safe(rc.get, MAINSECTION, 'dumpspectrum', "never", cfpath) self.gainpcs = self.gain.split(",") if len(self.gainpcs) != 4: print("Wrong gain string format in configuration %s, should be \"N,N,N,N\""%self.gain) sys.exit(1) if self.messgain < -1 or self.messgain > 3: print("messagin parameter must be an integer from range [-1, 3]") sys.exit(1) defaultgain = int(self.gainpcs[self.messgain]) self.minw = engnum(self.minw) self.maxw = engnum(self.maxw) self.rate = engnum(self.rate) files = [f for f in os.listdir(confdir) if os.path.isfile(os.path.join(confdir, f))] self.scanframes = [] self.cronframes = [] step = float(self.rate) * (1.0-self.overlap) # Read scanframe and channel config files for f in files: if f == "main.conf" or f == "blacklist.conf": continue if f[-5:] != ".conf": continue print("file %s"%f) rc = configparser.ConfigParser() rc.read(os.path.join(confdir, f)) floor = cfg_safe(rc.getfloat, MAINSECTION, 'floor', self.floor) sql = cfg_safe(rc.getfloat, MAINSECTION, 'sql', self.sql) stickactivity = cfg_safe(rc.getboolean, MAINSECTION, 'stickactivity', self.stickactivity) stick = cfg_safe(rc.getfloat, MAINSECTION, 'stick', self.stick) silencegap = cfg_safe(rc.getfloat, MAINSECTION, 'silencegap', self.silencegap) if "freqstart" in rc.options(MAINSECTION): # range randscan freqstart = rc.get(MAINSECTION, "freqstart") freqstart = engnum(freqstart) + step/2 freqstop = rc.get(MAINSECTION, "freqstop") freqstop = engnum(freqstop) - step/2 numf = int(math.ceil(float(freqstop - freqstart)/step)) if numf == 0: # freqstart == freqstop numf = 1 delta = freqstop else: delta = float(freqstop - freqstart) / numf cf = freqstart while cf <= math.ceil(freqstop): frm = scanframe() frm.freq = cf frm.floor = floor frm.stickactivity = stickactivity frm.stick = stick frm.silencegap = silencegap frm.sql = sql frm.gain = defaultgain self.scanframes.append(frm) print("insert %f"%cf) cf += math.floor(delta) elif "cron" in rc.options(MAINSECTION): # scheduled recording channels = self.channel_list_from_config(rc) frm = cronframe() frm.freq = engnum(rc.get(MAINSECTION, "freq")) frm.floor = self.floor frm.stickactivity = stickactivity frm.stick = stick frm.silencegap = silencegap frm.sql = sql frm.gain = defaultgain frm.cron = rc.get(MAINSECTION, "cron") frm.channels = channels self.cronframes.append(frm) randscan = cfg_safe(rc.getboolean, MAINSECTION, "randscan", True) if ((not ("freqstart" in rc.options(MAINSECTION))) and randscan): frm = scanframe() frm.freq = engnum(rc.get(MAINSECTION, "freq")) frm.floor = floor frm.stickactivity = stickactivity frm.stick = stick frm.silencegap = silencegap frm.sql = sql frm.gain = defaultgain channels = self.channel_list_from_config(rc) frm.channels = channels self.scanframes.append(frm) # read blacklist and archivelist blpath = os.path.join(confdir, "blacklist.conf") self.blacklist = self.read_sorted_list("h", blpath) self.archivelist = self.read_sorted_list("i", blpath)
def __init__(self): confdir = os.path.join(os.path.expanduser('~'), ".kukuruku/scanner/") # Read global config rc = configparser.ConfigParser() cfpath = os.path.join(confdir, "main.conf") rc.read(cfpath) self.bufsize = cfg_safe(rc.getint, MAINSECTION, 'bufsize', 2048000, cfpath) self.rate = cfg_safe(rc.getint, MAINSECTION, 'rate', 2048000, cfpath) self.interval = cfg_safe(rc.getint, MAINSECTION, 'interval', 5, cfpath) self.skip = cfg_safe(rc.getint, MAINSECTION, 'skip', 3, cfpath) self.fftw = cfg_safe(rc.getint, MAINSECTION, 'fftw', 2048, cfpath) self.fftskip = cfg_safe(rc.getint, MAINSECTION, 'fftskip', 32, cfpath) self.overlap = cfg_safe(rc.getfloat, MAINSECTION, 'overlap', 0.2, cfpath) self.nonce = cfg_safe(rc.get, MAINSECTION, 'nonce', "abcdef", cfpath) self.floor = cfg_safe(rc.getfloat, MAINSECTION, 'floor', 0.4, cfpath) self.sql = cfg_safe(rc.getfloat, MAINSECTION, 'sql', 0.5, cfpath) self.filtermargin = cfg_safe(rc.getfloat, MAINSECTION, 'filtermargin', 1.5, cfpath) self.transition = cfg_safe(rc.getfloat, MAINSECTION, 'transition', 0.2, cfpath) self.minw = cfg_safe(rc.get, MAINSECTION, 'minw', 10000, cfpath) self.maxw = cfg_safe(rc.get, MAINSECTION, 'maxw', 200000, cfpath) self.messgain = cfg_safe(rc.getint, MAINSECTION, 'messgain', 1, cfpath) self.mingain = cfg_safe(rc.getint, MAINSECTION, 'mingain', 10, cfpath) self.maxgain = cfg_safe(rc.getint, MAINSECTION, 'maxgain', 49, cfpath) self.gain = cfg_safe(rc.get, MAINSECTION, 'gain', "0,30,30,30", cfpath) self.stickactivity = cfg_safe(rc.getboolean, MAINSECTION, 'stickactivity', False, cfpath) self.stick = cfg_safe(rc.getint, MAINSECTION, 'stick', 10, cfpath) self.silencegap = cfg_safe(rc.getint, MAINSECTION, 'silencegap', 5, cfpath) self.dumpspectrum = cfg_safe(rc.get, MAINSECTION, 'dumpspectrum', "never", cfpath) self.gainpcs = self.gain.split(",") if len(self.gainpcs) != 4: print( "Wrong gain string format in configuration %s, should be \"N,N,N,N\"" % self.gain) sys.exit(1) if self.messgain < -1 or self.messgain > 3: print("messagin parameter must be an integer from range [-1, 3]") sys.exit(1) defaultgain = int(self.gainpcs[self.messgain]) self.minw = engnum(self.minw) self.maxw = engnum(self.maxw) self.rate = engnum(self.rate) files = [ f for f in os.listdir(confdir) if os.path.isfile(os.path.join(confdir, f)) ] self.scanframes = [] self.cronframes = [] step = float(self.rate) * (1.0 - self.overlap) # Read scanframe and channel config files for f in files: if f == "main.conf" or f == "blacklist.conf": continue if f[-5:] != ".conf": continue print("file %s" % f) rc = configparser.ConfigParser() rc.read(os.path.join(confdir, f)) floor = cfg_safe(rc.getfloat, MAINSECTION, 'floor', self.floor) sql = cfg_safe(rc.getfloat, MAINSECTION, 'sql', self.sql) stickactivity = cfg_safe(rc.getboolean, MAINSECTION, 'stickactivity', self.stickactivity) stick = cfg_safe(rc.getfloat, MAINSECTION, 'stick', self.stick) silencegap = cfg_safe(rc.getfloat, MAINSECTION, 'silencegap', self.silencegap) if "freqstart" in rc.options(MAINSECTION): # range randscan freqstart = rc.get(MAINSECTION, "freqstart") freqstart = engnum(freqstart) + step / 2 freqstop = rc.get(MAINSECTION, "freqstop") freqstop = engnum(freqstop) - step / 2 numf = int(math.ceil(float(freqstop - freqstart) / step)) if numf == 0: # freqstart == freqstop numf = 1 delta = freqstop else: delta = float(freqstop - freqstart) / numf cf = freqstart while cf <= math.ceil(freqstop): frm = scanframe() frm.freq = cf frm.floor = floor frm.stickactivity = stickactivity frm.stick = stick frm.silencegap = silencegap frm.sql = sql frm.gain = defaultgain self.scanframes.append(frm) print("insert %f" % cf) cf += math.floor(delta) elif "cron" in rc.options(MAINSECTION): # scheduled recording channels = self.channel_list_from_config(rc) frm = cronframe() frm.freq = engnum(rc.get(MAINSECTION, "freq")) frm.floor = self.floor frm.stickactivity = stickactivity frm.stick = stick frm.silencegap = silencegap frm.sql = sql frm.gain = defaultgain frm.cron = rc.get(MAINSECTION, "cron") frm.channels = channels self.cronframes.append(frm) randscan = cfg_safe(rc.getboolean, MAINSECTION, "randscan", True) if ((not ("freqstart" in rc.options(MAINSECTION))) and randscan): frm = scanframe() frm.freq = engnum(rc.get(MAINSECTION, "freq")) frm.floor = floor frm.stickactivity = stickactivity frm.stick = stick frm.silencegap = silencegap frm.sql = sql frm.gain = defaultgain channels = self.channel_list_from_config(rc) frm.channels = channels self.scanframes.append(frm) # read blacklist and archivelist blpath = os.path.join(confdir, "blacklist.conf") self.blacklist = self.read_sorted_list("h", blpath) self.archivelist = self.read_sorted_list("i", blpath)