def make_panel(wid, offset, bw, filtertype, transition, sql, afc): """ Create new xlater in model """ model.append(None) model[-1] = [ int(wid), libutil.safe_cast(offset, int, 0), filtertype, libutil.safe_cast(transition, int, 0), libutil.safe_cast(bw, int, 0), afc, sql, libutil.safe_cast(frequency + offset, int, 0) ]
def make_panel(wid, offset, bw, filtertype, transition, sql, afc): """ Create new xlater in model """ model.append(None) model[-1] = [ int(wid), libutil.safe_cast(offset, int, 0), filtertype, libutil.safe_cast(transition, int, 0), libutil.safe_cast(bw, int, 0), afc, sql, libutil.safe_cast(frequency + offset, int, 0), ]
def set_frequency(self, f): hdr = struct.pack(proto.ENDIAN+"i", proto.RETUNE) msg = c2s.CLI_RETUNE() msg.freq = libutil.safe_cast(f, int) self.q_msg(hdr + msg.SerializeToString())
def set_frequency(self, f): hdr = struct.pack(proto.ENDIAN + "i", proto.RETUNE) msg = c2s.CLI_RETUNE() msg.freq = libutil.safe_cast(f, int) self.q_msg(hdr + msg.SerializeToString())
def on_sql_change(widget, event): """ Handle edit in the SQL textbox """ global conf if not is_enter(event): return False conf.sqldelta = libutil.safe_cast(tb_sql.get_text(), float, conf.sqldelta) tb_sql.set_text(str(conf.sqldelta))
def croncmp(self, i, frag): """ Compare cron field (e.g. "*", "15" or "*/5"), return True on positive match. i - number to compare with frag - the cron field """ if frag == "*": return True if frag[:2] == "*/": num = safe_cast(frag[2:], int, None) if not num or num == 0: self.l.l("Invalid modulo number %s"%frag[2:], "CRIT") return False if i % num == 0: return True raw = safe_cast(frag, int, None) if raw is not None: if raw == i: return True return False
def on_ppm_change(widget, event): """ Handle edit in the PPM textbox """ global ppm if not is_enter(event): return False ppm = libutil.safe_cast(tb_ppm.get_text(), int, ppm) tb_ppm.set_text(str(ppm)) cl.set_ppm(ppm)
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 on_gain_change(widget, event): """ Handle edit in the Gain textbox """ if not is_enter(event): return False # if tb_gain.get_text() in ["a", "A", "auto"]: # cl.set_gain(1, [0]) # else: pieces = tb_gain.get_text().split(",") l = [] for p in pieces: l.append(libutil.safe_cast(p, int, 0)) cl.set_gain(l)
def on_gain_change(widget, event): """ Handle edit in the Gain textbox """ if not is_enter(event): return False #if tb_gain.get_text() in ["a", "A", "auto"]: # cl.set_gain(1, [0]) #else: pieces = tb_gain.get_text().split(",") l = [] for p in pieces: l.append(libutil.safe_cast(p, int, 0)) cl.set_gain(l)
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 float2color(f): """ Get color index from power readings """ idx = conf.spectrumscale*(f + conf.spectrumoffset) return max(0, min(libutil.safe_cast(idx, int, 0), len(colormap)-1))
def float2color(f): """ Get color index from power readings """ idx = conf.spectrumscale * (f + conf.spectrumoffset) return max(0, min(libutil.safe_cast(idx, int, 0), len(colormap) - 1))