From cf389a963941c2317bc533cd698667d495d52ba5 Mon Sep 17 00:00:00 2001 From: Larry Gadallah Date: Sun, 30 Jun 2019 21:11:46 -0700 Subject: [PATCH 1/3] Fixing invalid constant variable name warnings from PyLint --- FDLog.py | 1654 +++++++++++++++++++++++++++--------------------------- 1 file changed, 827 insertions(+), 827 deletions(-) diff --git a/FDLog.py b/FDLog.py index 0524de8..2cf288b 100755 --- a/FDLog.py +++ b/FDLog.py @@ -41,14 +41,14 @@ # Future: Adding interoperability with other programs such as HRDeluxe Free, # FLDigi, Rigserve etc if we can? -prog = 'FDLog_Enhanced v2019-FD-WE7U\n' \ +PROG = 'FDLog_Enhanced v2019-FD-WE7U\n' \ 'Copyright 2014-2019 by South Central Indiana Communications Support Group \n' \ 'Copyright 2019 by Curtis E. Mills (WE7U) \n' \ 'FDLog is under the GNU Public License v2 without warranty. \n' \ 'The original license file is in the folder. \n' -print prog +print PROG -about = """ +ABOUT = """ FDLog_Enhanced can be found on www.github.com GNU Public License V2 - in program folder. @@ -57,14 +57,14 @@ """ -version = "v18" -fontsize = 10 -fontinterval = 2 -typeface = 'Courier 10 pitch' +VERSION = "v18" +FONTSIZE = 10 +FONTINTERVAL = 2 +TYPEFACE = 'Courier 10 pitch' -fdfont = (typeface, fontsize) # regular fixed width font -fdmfont = (typeface, fontsize + fontinterval) # medium fixed width font -fdbfont = (typeface, fontsize + fontinterval * 2) # large fixed width font +FDFONT = (TYPEFACE, FONTSIZE) # regular fixed width font +FDMFONT = (TYPEFACE, FONTSIZE + FONTINTERVAL) # medium fixed width font +FDBFONT = (TYPEFACE, FONTSIZE + FONTINTERVAL * 2) # large fixed width font # Known Bug List @@ -111,7 +111,7 @@ def update(self): """periodic clock update every 30 seconds""" # Add line to get tmast variable (self.offset=float(gd.get('tmast',0)) from global database self.lock.acquire() # take semaphore - if node == string.lower(gd.getv('tmast')): + if NODE == string.lower(GD.getv('tmast')): if self.level != 0: print "Time Master" self.offset = 0 self.level = 0 @@ -136,7 +136,7 @@ def update(self): def calib(self, fnod, stml, td): "process time info in incoming pkt" - if fnod == node: + if fnod == NODE: return self.lock.acquire() # take semaphore # print "time fm",fnod,"lev",stml,"diff",td @@ -164,7 +164,7 @@ def adjust(self): print "Slewing clock", adj, "to", self.offset -mclock = clock_class() +MCLOCK = clock_class() def initialize(): k = "" # keyboard input @@ -193,19 +193,19 @@ def initialize(): if z != "1": print "Press F, W or V please" if k == "f": kfd = 1 #used later to skip grid square question.SAH - globDb.put('contst', "FD") - qdb.globalshare('contst', "FD") # global to db + GLOBDB.put('contst', "FD") + QDB.globalshare('contst', "FD") # global to db renew_title() print "Have a nice Field Day!" if k == "w": kfd = 2 #used later to skip grid square question - globDb.put('contst', "WFD") - qdb.globalshare('contst', "WFD") # global to db + GLOBDB.put('contst', "WFD") + QDB.globalshare('contst', "WFD") # global to db renew_title() print "Have a nice Field Day!" if k == "v": - globDb.put('contst', "VHF") - qdb.globalshare('contst', "VHF") # global to db + GLOBDB.put('contst', "VHF") + QDB.globalshare('contst', "VHF") # global to db renew_title() print "Enjoy the VHF contest!" # Name of the club or group @@ -214,8 +214,8 @@ def initialize(): while k == "": print "Please type the name of your club or group" k = string.strip(sys.stdin.readline()) - globDb.put('grpnam', k) - qdb.globalshare('grpnam', k) # global to db + GLOBDB.put('grpnam', k) + QDB.globalshare('grpnam', k) # global to db renew_title() print k, "is a nice name." # Club Call @@ -224,8 +224,8 @@ def initialize(): while k == "": print "Please type the club call." k = string.strip(sys.stdin.readline()) - globDb.put('fdcall', k) - qdb.globalshare('fdcall', k) # global to db + GLOBDB.put('fdcall', k) + QDB.globalshare('fdcall', k) # global to db renew_title() print k, "will be the club call." # Gota Call @@ -236,8 +236,8 @@ def initialize(): print "Please type the GOTA call. (if none type none)" k = string.strip(sys.stdin.readline()) else: - globDb.put('gcall', k) - qdb.globalshare('gcall', k) # global to db + GLOBDB.put('gcall', k) + QDB.globalshare('gcall', k) # global to db renew_title() print k, "will be the GOTA call." # Class @@ -247,8 +247,8 @@ def initialize(): print "Please type the class." k = string.strip(sys.stdin.readline()) else: - globDb.put('class', k) - qdb.globalshare('class', k) # global to db + GLOBDB.put('class', k) + QDB.globalshare('class', k) # global to db renew_title() print k, "will be the class." # Section @@ -258,8 +258,8 @@ def initialize(): print "Please type the section (like KY-Kentucky)." k = string.strip(sys.stdin.readline()) else: - globDb.put('sect', k) - qdb.globalshare('sect', k) # global to db + GLOBDB.put('sect', k) + QDB.globalshare('sect', k) # global to db renew_title() print k, "will be the section." if kfd == 0: @@ -271,8 +271,8 @@ def initialize(): k = string.strip(sys.stdin.readline()) k = k.upper() # changed the init so the grid square will be cap else: - globDb.put('grid', k) - qdb.globalshare('grid', k) # global to db + GLOBDB.put('grid', k) + QDB.globalshare('grid', k) # global to db renew_title() print k, "will be the grid." if kfd !=2: @@ -287,13 +287,13 @@ def initialize(): if k == "n": z = '1' if z == "" : print "Press Y or N please" if k == "y": - globDb.put('public', "A public location") - qdb.globalshare('public', "A public location") # global to db + GLOBDB.put('public', "A public location") + QDB.globalshare('public', "A public location") # global to db renew_title() print "Enjoy the public place." if k == "n": - globDb.put('public', "") - qdb.globalshare('public', "") # global to db + GLOBDB.put('public', "") + QDB.globalshare('public', "") # global to db renew_title() print "maybe next year..." # Info Booth @@ -306,13 +306,13 @@ def initialize(): if k == "n": z = '1' if z == "" : print "Press Y or N please" if k == "y": - globDb.put('infob', "1") - qdb.globalshare('infob', "1") # global to db + GLOBDB.put('infob', "1") + QDB.globalshare('infob', "1") # global to db renew_title() print "Love information tables!" if k == "n": - globDb.put('infob', "0") - qdb.globalshare('infob', "0") # global to db + GLOBDB.put('infob', "0") + QDB.globalshare('infob', "0") # global to db renew_title() print "An information table is easy points" #Time Master - oh yeah the big question @@ -328,8 +328,8 @@ def initialize(): if k == "n": z = '1' if z == "" : print "Press Y or N please" if k == "y": - globDb.put('tmast', node) - qdb.globalshare('tmast', node) # global to db + GLOBDB.put('tmast', NODE) + QDB.globalshare('tmast', NODE) # global to db renew_title() print "Time travels to you!" if k == "n": @@ -355,7 +355,7 @@ def exin(op): class SQDB: def __init__(self): - self.dbPath = logdbf[0:-4] + '.sq3' + self.dbPath = LOGDBF[0:-4] + '.sq3' print "Using database", self.dbPath self.sqdb = sqlite3.connect(self.dbPath, check_same_thread=False) # connect to the database # Have to add FALSE here to get this stable @@ -415,9 +415,9 @@ def new(self, source): return n def tolog(self): # make log file entry - sqdb.log(self) # to database + SQDB.log(self) # to database self.lock.acquire() # and to ascii journal file as well - fd = file(logdbf, "a") + fd = file(LOGDBF, "a") fd.write("\nq|%s|%s|%s|%s|%s|%s|%s|%s|%s|" % \ (self.src, self.seq, self.date, self.band, self.call, self.rept, @@ -435,12 +435,12 @@ def ldrec(self, line): # load log entry fm text def loadfile(self): print "Loading Log File" i, s, log = 0, 0, [] - global sqdb # setup sqlite database connection - sqdb = SQDB() - log = sqdb.readlog() # read the database + global SQDB # setup sqlite database connection + SQDB = SQDB() + log = SQDB.readlog() # read the database for ln in log: if ln[0] == 'q': # qso db line - r = qdb.new(0) + r = QDB.new(0) try: r.ldrec(ln) i += 1 @@ -462,7 +462,7 @@ def loadfile(self): def cleanlog(self): """return clean filtered dictionaries of the log""" d, c, g = {}, {}, {} - fdstart, fdend = gd.getv('fdstrt'), gd.getv('fdend') + fdstart, fdend = GD.getv('fdstrt'), GD.getv('fdend') self.lock.acquire() for i in self.byid.values(): # copy, index by node, sequence k = "%s|%s" % (i.src, i.seq) @@ -554,8 +554,8 @@ def vhf_cabrillo(self): "output VHF contest cabrillo QSO data" band_map = {'6': '50', '2': '144', '220': '222', '440': '432', '900': '902', '1200': '1.2G'} dummy, n, dummy = self.cleanlog() - mycall = string.upper(gd.getv('fdcall')) - mygrid = gd.getv('grid') + mycall = string.upper(GD.getv('fdcall')) + mygrid = GD.getv('grid') l = [] print "QSO: freq mo date time call grid call grid " for i in n.values(): # + g.values(): no gota in vhf @@ -582,9 +582,9 @@ def winter_fd(self): band_map = {'160': '1800', '80': '3500', '40': '7000', '20': '14000','15': '21000','10': '28000','6': '50', '2': '144', '220': '222', '440': '432', '900': '902', '1200': '1.2G'} dummy, n, dummy = self.cleanlog() l = [] - mycall = string.upper(gd.getv('fdcall')) - mycat = gd.getv('class') - mystate, mysect = gd.getv('sect').split("-") + mycall = string.upper(GD.getv('fdcall')) + mycat = GD.getv('class') + mystate, mysect = GD.getv('sect').split("-") #number of tx txnum = mycat[:-1] #data crunching: @@ -611,7 +611,7 @@ def winter_fd(self): #check operator (single or multi op): cat_op = "" - if len(participants) > 1: + if len(PARTICIPANTS) > 1: cat_op = "MULTI-OP" else: cat_op = "SINGLE-OP" @@ -624,7 +624,7 @@ def winter_fd(self): ops_calls_list = [] #print(participants) #participants: {u'am': u'am, art miller, kc7sda, 37, '} - for i in participants.values(): + for i in PARTICIPANTS.values(): dummy, dummy, cs, dummy, dummy = i.split(", ") ops_calls_list.append(string.upper(cs)) ops_calls = ', '.join(ops_calls_list) @@ -648,13 +648,13 @@ def winter_fd(self): print "SOAPBOX: " #fill in? print "CLAIMED-SCORE: " #figure out score and add print "OPERATORS: " + ops_calls #agregate the ops - print "NAME: " + gd.getv('fmname') - print "ADDRESS: " + gd.getv('fmad1') - print "ADDRESS-CITY: " + gd.getv('fmcity') - print "ADDRESS-STATE: " + gd.getv('fmst') - print "ADDRES-POSTALCODE: " + gd.getv('fmzip') #zip + print "NAME: " + GD.getv('fmname') + print "ADDRESS: " + GD.getv('fmad1') + print "ADDRESS-CITY: " + GD.getv('fmcity') + print "ADDRESS-STATE: " + GD.getv('fmst') + print "ADDRES-POSTALCODE: " + GD.getv('fmzip') #zip print "ADDRESS-COUNTRY: USA" # hard coded for now, possibly change later - print "EMAIL: " + gd.getv('fmem') #email address + print "EMAIL: " + GD.getv('fmem') #email address #print log: for i in l: print i[13:] # rm sort key date.time print "END-OF-LOG:" @@ -707,13 +707,13 @@ def postnewinfo(self, time, call, bandmod, report): # s.date,s.call,s.band,s.rept,s.oper,s.logr,s.powr = # time,call,bandmod,report,exin(operator),exin(logger),power # s.seq = -1 - return self.postnew(time, call, bandmod, report, exin(operator), - exin(logger), power) + return self.postnew(time, call, bandmod, report, exin(OPERATOR), + exin(LOGGER), POWER) # s.dispatch('user') # removed in 152i def postnew(self, time, call, bandmod, report, oper, logr, powr): "post new locally generated info" - s = self.new(node) + s = self.new(NODE) s.date, s.call, s.band, s.rept, s.oper, s.logr, s.powr = time, call, bandmod, report, oper, logr, powr s.seq = -1 return s.dispatch('user') @@ -726,15 +726,15 @@ def delete(self, nod, seq, reason): if a.has_key(k) and a[k].band[0] != '*': # only visible q tm, call, bandmod = a[k].date, a[k].call, a[k].band rept = "*del:%s:%s:%s" % (nod, seq, reason) - s = self.new(node) + s = self.new(NODE) s.date, s.call, s.band, s.rept, s.oper, s.logr, s.powr = \ - now(), call, bandmod, rept, exin(operator), exin(logger), 0 + now(), call, bandmod, rept, exin(OPERATOR), exin(LOGGER), 0 s.seq = -1 s.dispatch('user') - txtbillb.insert(END, " DELETE Successful %s %s %s\n" % (tm, call, bandmod)) - logw.configure(state=NORMAL) - logw.delete(0.1,END) - logw.insert(END, "\n") + TXTBILLB.insert(END, " DELETE Successful %s %s %s\n" % (tm, call, bandmod)) + LOGW.configure(state=NORMAL) + LOGW.delete(0.1, END) + LOGW.insert(END, "\n") # Redraw the logw text window (on delete) to only show valid calls in the log. # This avoids confusion by only listing items in the log to edit in the future. l = [] @@ -742,16 +742,16 @@ def delete(self, nod, seq, reason): if i.seq == seq: continue else: - l.append(logw.insert(END, "\n")) - if nod == node: - l.append(logw.insert(END, i.prlogln(i), "b")) + l.append(LOGW.insert(END, "\n")) + if nod == NODE: + l.append(LOGW.insert(END, i.prlogln(i), "b")) else: - l.append(logw.insert(END, i.prlogln(i))) - l.append(logw.insert(END, "\n")) - logw.insert(END, "\n") - logw.configure(state=DISABLED) + l.append(LOGW.insert(END, i.prlogln(i))) + l.append(LOGW.insert(END, "\n")) + LOGW.insert(END, "\n") + LOGW.configure(state=DISABLED) else: - txtbillb.insert(END, " DELETE Ignored [%s,%s] Not Found\n" % (nod, seq)) + TXTBILLB.insert(END, " DELETE Ignored [%s,%s] Not Found\n" % (nod, seq)) topper() def todb(self): @@ -766,7 +766,7 @@ def todb(self): # if debug: print "todb:",self.src,self.seq r = self elif self.seq == current: - if debug: print "dup sequence log entry ignored" + if DEBUG: print "dup sequence log entry ignored" else: print "out of sequence log entry ignored", self.seq, current + 1 self.lock.release() @@ -774,7 +774,7 @@ def todb(self): def pr(self): """"print Q record object""" - sms.prmsg(self.prlogln(self)) + SMS.prmsg(self.prlogln(self)) def dispatch(self, src): """"process new db rec (fm logf,user,net) to where it goes""" @@ -787,9 +787,9 @@ def dispatch(self, src): if r: # if new self.pr() if src != 'logf': self.tolog() - if src == 'user': net.bc_qsomsg(self.src, self.seq) + if src == 'user': NET.bc_qsomsg(self.src, self.seq) if self.band == '*set': - m = gd.setv(r.call, r.rept, r.date) + m = GD.setv(r.call, r.rept, r.date) if not m: r = None else: self.logdup() @@ -864,7 +864,7 @@ def bands(self): print print "Stations this node is hearing:" # scan for stations on bands - for s in net.si.nodes.values(): # xx + for s in NET.si.nodes.values(): # xx # print dir(s) print s.nod, s.host, s.ip, s.stm # nod[s.bnd] = s.nod_on_band() @@ -875,7 +875,7 @@ def bands(self): print print "Node Info" print "--node-- band --opr lgr pwr----- last" - for t in net.si.nodinfo.values(): + for t in NET.si.nodinfo.values(): dummy, dummy, age = d.get(t.nod, ('', '', 9999)) if age > t.age: d[t.nod] = (t.bnd, t.msc, t.age) for t in d: @@ -904,7 +904,7 @@ def bands(self): # t = "" # time of latest Q hhmm # m = re.search(r"([0-9]{4})[0-9]{2}$",tmlq.get(bm,'')) # if m: t = m.group(1) - nob = net.si.nod_on_band(bm) # node now on band + nob = NET.si.nod_on_band(bm) # node now on band if len(nob) == 0: nob = '' # list take first item if any else: @@ -987,7 +987,7 @@ def qparse(self, line): def dupck(self, wcall, band): """check for duplicate call on this band""" dummy, dummy, dummy, sfx, call, xcall, dummy = self.qparse(wcall) - if gd.getv('contst').upper() == "VHF": + if GD.getv('contst').upper() == "VHF": return xcall in self.sfx2call(sfx, band) # vhf contest return call in self.sfx2call(sfx, band) # field day @@ -997,17 +997,17 @@ def partck(self, wcall): """ check for participants to act as dupes in this event""" dummy, dummy, dummy, dummy, call, xcall, dummy = self.qparse(wcall) l = [] - for i in participants.values(): + for i in PARTICIPANTS.values(): l.append(i) dummy, dummy, dcall, dummy, dummy = string.split(i, ', ') if dcall == xcall: # to debug: print ("%s dcall matches %s xcall" % (dcall, xcall)) - if gd.getv('contst').upper() == "VHF": + if GD.getv('contst').upper() == "VHF": return xcall # vhf contest return call # field day if dcall == call: #to debug: print ("%s dcall matches %s call" % (dcall, call)) - if gd.getv('contst').upper() == "VHF": + if GD.getv('contst').upper() == "VHF": return xcall # vhf contest return call # field day @@ -1023,7 +1023,7 @@ def logdup(self): # duplog everything with nonzero power, or on band off (test) if (self.band == 'off') | (ival(self.powr) > 0): # dup only if Q and node type match (gota/not) - if (node == 'gotanode') == (self.src == 'gotanode'): + if (NODE == 'gotanode') == (self.src == 'gotanode'): if self.bysfx.has_key(key): # add to suffix db self.bysfx[key].append(xcall) else: @@ -1112,7 +1112,7 @@ class node_info: def sqd(self, src, seq, t, b, c, rp, p, o, l): """process qso data fm net into db""" # excessive cohesion? - s = qdb.new(src) + s = QDB.new(src) s.seq, s.date, s.call, s.band, s.rept, s.oper, s.logr, s.powr = \ seq, t, c, b, rp, o, l, p s.dispatch('net') @@ -1131,7 +1131,7 @@ def ssb(self, pkt_tm, host, sip, nod, stm, stml, ver, td): self.lock.acquire() if not self.nodes.has_key(nod): # create if new self.nodes[nod] = node_info() - if nod != node: + if nod != NODE: print "New Node Heard", host, sip, nod, stm, stml, ver, td i = self.nodes[nod] # if debug: print "ssb before assign",i.nod,i.stm,i.bnd @@ -1175,7 +1175,7 @@ def fill_requests_list(self): r = [] self.lock.acquire() for i in self.nodinfo.values(): # for each node - j = qdb.hiseq.get(i.nod, 0) + j = QDB.hiseq.get(i.nod, 0) if int(i.seq) > j: # if they have something we need r.append((i.fip, i.nod, j + 1)) # add req for next to list # if debug: print "req fm",i.fip,"for",i.nod,i.seq,"have",j+1 @@ -1187,10 +1187,10 @@ def node_status_list(self): sum = {} # summary dictionary self.lock.acquire() i = node_info() # update our info - i.nod, i.bnd, i.age = node, band, 0 - i.msc = "%s %s %sW" % (exin(operator), exin(logger), power) - sum[node] = i - for i in qdb.hiseq.keys(): # insure all db nod on list + i.nod, i.bnd, i.age = NODE, BAND, 0 + i.msc = "%s %s %sW" % (exin(OPERATOR), exin(LOGGER), POWER) + sum[NODE] = i + for i in QDB.hiseq.keys(): # insure all db nod on list if not sum.has_key(i): # add if new j = node_info() j.nod, j.bnd, j.msc, j.age = i, '', '', 999 @@ -1213,7 +1213,7 @@ def node_status_list(self): self.lock.release() r = [] # form the list (xx return sum?) for s in sum.values(): - seq = qdb.hiseq.get(s.nod, 0) # reflect what we have in our db + seq = QDB.hiseq.get(s.nod, 0) # reflect what we have in our db if seq or s.bnd: # only report interesting info r.append((s.nod, seq, s.bnd, s.msc, s.age)) return r # list of (nod,seq,bnd,msc,age) @@ -1275,8 +1275,8 @@ def setport(self, useport): def setauth(self, newauth): """set authentication key code base, copy on use""" - global authk - authk = newauth + global AUTHK + AUTHK = newauth seed = "2004070511111akb" # change when protocol changes # self.authkey = md5.new(newauth+seed) @@ -1296,7 +1296,7 @@ def ckauth(self, msg): def sndmsg(self, msg, addr): """send message to address list""" - if authk != "" and node != "": + if AUTHK != "" and NODE != "": amsg = self.auth(msg) + '\n' + msg addrlst = [] if addr == 'bcast': @@ -1306,7 +1306,7 @@ def sndmsg(self, msg, addr): for a in addrlst: if a == "": continue if a == '0.0.0.0': continue - if debug: print "send to ", a; print msg + if DEBUG: print "send to ", a; print msg try: self.skt.sendto(amsg, (a, self.port)) except socket.error, e: @@ -1316,8 +1316,8 @@ def sndmsg(self, msg, addr): def send_qsomsg(self, nod, seq, destip): """send q record""" key = nod + '.' + str(seq) - if qdb.byid.has_key(key): - i = qdb.byid[key] + if QDB.byid.has_key(key): + i = QDB.byid[key] msg = "q|%s|%s|%s|%s|%s|%s|%s|%s|%s\n" % \ (i.src, i.seq, i.date, i.band, i.call, i.rept, i.powr, i.oper, i.logr) self.sndmsg(msg, destip) @@ -1328,7 +1328,7 @@ def bc_qsomsg(self, nod, seq): def bcast_now(self): msg = "b|%s|%s|%s|%s|%s|%s\n" % \ - (self.hostname, self.my_addr, node, now(), mclock.level, version) + (self.hostname, self.my_addr, NODE, now(), MCLOCK.level, VERSION) for i in self.si.node_status_list(): msg += "s|%s|%s|%s|%s|%s\n" % i # nod,seq,bnd,msc,age # if debug: print i @@ -1337,11 +1337,11 @@ def bcast_now(self): def fillr(self): """filler thread requests missing database records""" time.sleep(0.2) - if debug: print "filler thread starting" + if DEBUG: print "filler thread starting" while 1: time.sleep(.1) # periodically check for fills - if debug: time.sleep(1) # slow for debug + if DEBUG: time.sleep(1) # slow for debug r = self.si.fill_requests_list() self.fills = len(r) if self.fills: @@ -1353,7 +1353,7 @@ def fillr(self): def rcvr(self): """receiver thread processes incoming packets""" - if debug: print "receiver thread starting" + if DEBUG: print "receiver thread starting" r = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) r.bind(('', self.port)) while 1: @@ -1363,7 +1363,7 @@ def rcvr(self): # if authk == "": continue # skip till auth set pkt_tm = now() host, sip, fnod, stm = '', '', '', '' - if debug: print "rcvr: %s: %s" % (addr, msg), # xx + if DEBUG: print "rcvr: %s: %s" % (addr, msg), # xx if not self.ckauth(msg): # authenticate packet # if debug: sms.prmsg("bad auth from: %s"%addr) print "bad auth from:", addr @@ -1377,10 +1377,10 @@ def rcvr(self): host, sip, fnod, stm, stml, ver = fields[1:] td = tmsub(stm, pkt_tm) self.si.ssb(pkt_tm, host, sip, fnod, stm, stml, ver, td) - mclock.calib(fnod, stml, td) - if abs(td) >= tdwin: + MCLOCK.calib(fnod, stml, td) + if abs(td) >= TDWIN: print 'Incoming packet clock error', td, host, sip, fnod, pkt_tm - if showbc: + if SHOWBC: print "bcast", host, sip, fnod, ver, pkt_tm, td elif fields[0] == 's': # source status nod, seq, bnd, msc, age = fields[1:] @@ -1395,7 +1395,7 @@ def rcvr(self): # if debug: print src,seq,stm,b,c,rp,p,o,l self.si.sqd(src, seq, stm, b, c, rp, p, o, l) else: - sms.prmsg("msg not recognized %s" % addr) + SMS.prmsg("msg not recognized %s" % addr) def start(self): """launch all threads""" @@ -1408,7 +1408,7 @@ def start(self): # thread.start_new_thread(self.bcastr,()) thread.start_new_thread(self.fillr, ()) thread.start_new_thread(self.rcvr, ()) - if debug: + if DEBUG: print "threads launched" time.sleep(0.5) # let em print print "Startup complete" @@ -1430,8 +1430,8 @@ def new(self, name, desc, defaultvalue, okgrammar, maxlen): return i def setv(self, name, value, timestamp): - if node == "": - txtbillb.insert(END, "error - no node id\n") + if NODE == "": + TXTBILLB.insert(END, "error - no node id\n") return if name[:2] == 'p:': # set oper/logr i = self.byname.get(name, self.new(name, '', '', '', 0)) @@ -1450,9 +1450,9 @@ def setv(self, name, value, timestamp): i.ts = timestamp if name[:2] == 'p:': ini, name, dummy, dummy, dummy = string.split(value, ', ') - participants[ini] = value + PARTICIPANTS[ini] = value if name == 'delete': - del (participants[ini]) + del (PARTICIPANTS[ini]) buildmenus() # else: print "set warning - older value discarded" @@ -1471,7 +1471,7 @@ def sethelp(self): # modifed the sect setting regex to accept both lower and upper case # added additional form fields (also fixed 'from' to 'form') for wfd NOTE: set commands have a max length of 6! -gd = global_data() +GD = global_data() for name, desc, default, okre, maxlen in ( ('class', ' FD class (eg 2A)', '2A', r'[1-9][0-9]?[a-fihoA-FIHO]$', 3), ('contst', ' Contest (FD,WFD,VHF)', 'FD', r'fd|FD|wfd|WFD|vhf|VHF$', 3), @@ -1501,7 +1501,7 @@ def sethelp(self): ('fdstrt', 'yymmdd.hhmm FD start time (UTC)', '020108.1800', r'[0-9.]{11}$', 11), ('fdend', 'yymmdd.hhmm FD end time (UTC)', '990629.2100', r'[0-9.]{11}$', 11), ('tmast', ' Time Master Node', '', r'[A-Za-z0-9-]{0,8}$', 8)): - gd.new(name, desc, default, okre, maxlen) + GD.new(name, desc, default, okre, maxlen) class syncmsg: @@ -1520,21 +1520,21 @@ def prout(self): # Check to see if the log window has been deleted self.lock.acquire() while self.msgs: - logw.configure(state=NORMAL) - logw.see(END) + LOGW.configure(state=NORMAL) + LOGW.see(END) nod = self.msgs[0][70:81] # color local entries seq = self.msgs[0][65:69].strip() seq = int(seq) stn = self.msgs[0][69:].strip() - if nod == node: + if nod == NODE: # Added a check to see if in the log to print blue or not - bid, dummy, dummy = qdb.cleanlog() # get a clean log + bid, dummy, dummy = QDB.cleanlog() # get a clean log stnseq = stn +"|"+str(seq) if stnseq in bid: - logw.insert(END, "%s\n" % self.msgs[0], "b") + LOGW.insert(END, "%s\n" % self.msgs[0], "b") else: - logw.insert(END, "%s\n" % self.msgs[0]) - logw.configure(state=DISABLED) + LOGW.insert(END, "%s\n" % self.msgs[0]) + LOGW.configure(state=DISABLED) del self.msgs[0] self.lock.release() @@ -1544,7 +1544,7 @@ def prout(self): def now(): """return current time in standard string format""" # n = time.localtime(time.time()) - n = time.gmtime(time.time() + mclock.offset) # time in gmt utc + n = time.gmtime(time.time() + MCLOCK.offset) # time in gmt utc # offset to correct to master t = time.strftime("%y%m%d.%H%M%S", n) # compact version YY return t @@ -1565,7 +1565,7 @@ def tmsub(a, b): class GlobalDb: """new sqlite globals database fdlog.sq3 replacing globals file""" def __init__(self): - self.dbPath = globf[0:-4] + '.sq3' + self.dbPath = GLOBF[0:-4] + '.sq3' print " Using local value database", self.dbPath self.sqdb = sqlite3.connect(self.dbPath, check_same_thread=False) # connect to the database # Have to add FALSE here to get this stable. @@ -1603,30 +1603,30 @@ def put(self, name, value): def loadglob(): """load persistent local config to global vars from file""" # updated from 152i - global globDb, node, operator, logger, power, tdwin, debug, authk, timeok - globDb = GlobalDb() - node = globDb.get('node', '') - operator = globDb.get('operator', '') - logger = globDb.get('logger', '') - power = globDb.get('power', '0') - authk = globDb.get('authk', 'tst') - tdwin = int(globDb.get('tdwin', 5)) # 152i changed from 10 to 5 - debug = int(globDb.get('debug', 0)) - timeok = int(globDb.get('timeok', 0)) - netsync.rem_host = globDb.get('remip', '0.0.0.0') - if debug: print " debug:", debug + global GLOBDB, NODE, OPERATOR, LOGGER, POWER, TDWIN, DEBUG, AUTHK, TIMEOK + GLOBDB = GlobalDb() + NODE = GLOBDB.get('node', '') + OPERATOR = GLOBDB.get('operator', '') + LOGGER = GLOBDB.get('logger', '') + POWER = GLOBDB.get('power', '0') + AUTHK = GLOBDB.get('authk', 'tst') + TDWIN = int(GLOBDB.get('tdwin', 5)) # 152i changed from 10 to 5 + DEBUG = int(GLOBDB.get('debug', 0)) + TIMEOK = int(GLOBDB.get('timeok', 0)) + netsync.rem_host = GLOBDB.get('remip', '0.0.0.0') + if DEBUG: print " debug:", DEBUG def saveglob(): """save persistent local config global vars to file""" - globDb.put('node', node) - globDb.put('operator', operator) - globDb.put('logger', logger) - globDb.put('power', power) - globDb.put('authk', authk) - globDb.put('tdwin', tdwin) - globDb.put('debug', debug) - globDb.put('timeok', timeok) + GLOBDB.put('node', NODE) + GLOBDB.put('operator', OPERATOR) + GLOBDB.put('logger', LOGGER) + GLOBDB.put('power', POWER) + GLOBDB.put('authk', AUTHK) + GLOBDB.put('tdwin', TDWIN) + GLOBDB.put('debug', DEBUG) + GLOBDB.put('timeok', TIMEOK) # fd = file(globf,"w") # fd.write("|%s|%s|%s|%s|%s|%s|%s|"%(node,operator,logger,power,\ # authk,tdwin,debug)) @@ -1649,7 +1649,7 @@ def getfile(fn): return data -participants = {} +PARTICIPANTS = {} def contestlog(pr): @@ -1665,20 +1665,20 @@ def contestlog(pr): nts_msg_relay.append(msg) media_copy = getfile("media.txt") # media activity soapbox = getfile("soapbox.txt") # soapbox commentary - fd_call = string.upper(gd.getv('fdcall')) # prep data - xmttrs = ival(gd.getv('class')) - gota_call = string.upper(gd.getv('gcall')) + fd_call = string.upper(GD.getv('fdcall')) # prep data + xmttrs = ival(GD.getv('class')) + gota_call = string.upper(GD.getv('gcall')) if xmttrs < 2: gota_call = "" if pr == 0: return # only define variables return # output the entry, adif & cabrillo log file datime = now() - dummy, bycall, gotabycall = qdb.cleanlog() # get a clean log + dummy, bycall, gotabycall = QDB.cleanlog() # get a clean log qpb, ppb, qpop, qplg, qpst, dummy, dummy, maxp, cwq, digq, fonq, qpgop, gotaq, nat, sat = \ - qdb.bandrpt() # and count it + QDB.bandrpt() # and count it print "..", - sys.stdout = file(logfile, "w") # redirect output to file + sys.stdout = file(LOGFILE, "w") # redirect output to file print "Field Day 20%s Entry Form" % datime[:2] print print "Date Prepared: %s UTC" % datime[:-2] @@ -1686,23 +1686,23 @@ def contestlog(pr): print "1. Field Day Call: %s" % fd_call if gota_call != "": print " GOTA Station Call: %s" % gota_call - print "2. Club or Group Name: %s" % gd.getv('grpnam') - print "3. Number of Participants: %s" % len(participants) + print "2. Club or Group Name: %s" % GD.getv('grpnam') + print "3. Number of Participants: %s" % len(PARTICIPANTS) print "4. Transmitter Class: %s" % xmttrs - print "5. Entry Class: %s" % string.upper(gd.getv('class'))[-1:] + print "5. Entry Class: %s" % string.upper(GD.getv('class'))[-1:] print print "6. Power Sources Used:" - if int(gd.getv('psgen')) > 0: + if int(GD.getv('psgen')) > 0: print " Generator" - if int(gd.getv('pscom')) > 0: + if int(GD.getv('pscom')) > 0: print " Commercial" - if int(gd.getv('psbat')) > 0: + if int(GD.getv('psbat')) > 0: print " Battery" # add solar! xx - if gd.getv('psoth') != '': - print " Other: %s" % (gd.getv('psoth')) + if GD.getv('psoth') != '': + print " Other: %s" % (GD.getv('psoth')) print - print "7. ARRL Section: %s" % gd.getv('sect') + print "7. ARRL Section: %s" % GD.getv('sect') print print "8. Total CW QSOs: %4s Points: %5s" % (cwq, cwq * 2) print "9. Total Digital QSOs: %4s Points: %5s" % (digq, digq * 2) @@ -1711,7 +1711,7 @@ def contestlog(pr): print "11. Total QSO Points: %5s" % qsop print "12. Max Power Used: %4s Watts" % maxp powm = 5 - if int(gd.getv('psgen')) > 0 or int(gd.getv('pscom')) > 0: powm = 2 + if int(GD.getv('psgen')) > 0 or int(GD.getv('pscom')) > 0: powm = 2 if maxp > 5: powm = 2 if maxp > 150: @@ -1725,7 +1725,7 @@ def contestlog(pr): print "15. Bonus Points:" tot_bonus = 0 emerg_powr_bp = 0 - if gd.getv('pscom') == '0': + if GD.getv('pscom') == '0': emerg_powr_bp = 100 * xmttrs if emerg_powr_bp > 2000: emerg_powr_bp = 2000 @@ -1737,13 +1737,13 @@ def contestlog(pr): tot_bonus += media_pub_bp print " %3s Media Publicity (copy below)" % media_pub_bp public_bp = 0 - public_place = gd.getv('public') + public_place = GD.getv('public') if public_place != "": public_bp = 100 tot_bonus += public_bp print " %3s Set-up in a Public Place (%s)" % (public_bp, public_place) info_booth_bp = 0 - if int(gd.getv('infob')) > 0 and public_bp > 0: + if int(GD.getv('infob')) > 0 and public_bp > 0: info_booth_bp = 100 tot_bonus += info_booth_bp print " %3s Information Booth (photo included)" % info_booth_bp @@ -1777,30 +1777,30 @@ def contestlog(pr): tot_bonus += w1aw_msg_bp print " %3s W1AW FD Message Received (copy below)" % (w1aw_msg_bp) site_visited_ego_bp = 0 - if gd.getv('svego') > "": + if GD.getv('svego') > "": site_visited_ego_bp = 100 tot_bonus += site_visited_ego_bp - print " %3s Site Visited by elected govt officials (%s)" % (site_visited_ego_bp, gd.getv('svego')) + print " %3s Site Visited by elected govt officials (%s)" % (site_visited_ego_bp, GD.getv('svego')) site_visited_roa_bp = 0 - if gd.getv('svroa') > "": + if GD.getv('svroa') > "": site_visited_roa_bp = 100 tot_bonus += site_visited_roa_bp - print " %3s Site Visited by representative of agency (%s)" % (site_visited_roa_bp, gd.getv('svroa')) + print " %3s Site Visited by representative of agency (%s)" % (site_visited_roa_bp, GD.getv('svroa')) gota_max_bp = 0 if gotaq >= 100: gota_max_bp = 100 tot_bonus += gota_max_bp print " %3s GOTA Station 100 QSOs bonus achieved" % (gota_max_bp) youth_bp = 0 - if int(gd.getv('youth')) > 0: - youth_bp = 20 * int(gd.getv('youth')) + if int(GD.getv('youth')) > 0: + youth_bp = 20 * int(GD.getv('youth')) if youth_bp > 5 * 20: youth_bp = 5 * 20 tot_bonus += youth_bp print " %3s Youth Participation Bonus" % (youth_bp) # keep this last web_sub_bp = 0 - if gd.getv('websub') == "1": + if GD.getv('websub') == "1": web_sub_bp = 50 tot_bonus += web_sub_bp print " %3s Web Submission Bonus" % (web_sub_bp) @@ -1818,11 +1818,11 @@ def contestlog(pr): print "Submitted By:" print print " Date: %s UTC" % datime[:-2] - print " Call: %s" % string.upper(gd.getv('fmcall')) - print " Name: %s" % gd.getv('fmname') - print " Address: %s" % gd.getv('fmad1') - print " Address: %s" % gd.getv('fmad2') - print " Email: %s" % gd.getv('fmem') + print " Call: %s" % string.upper(GD.getv('fmcall')) + print " Name: %s" % GD.getv('fmname') + print " Address: %s" % GD.getv('fmad1') + print " Address: %s" % GD.getv('fmad2') + print " Email: %s" % GD.getv('fmem') print print print "Field Day Call: %s" % string.upper(fd_call) @@ -1966,7 +1966,7 @@ def contestlog(pr): print print print "Logging and Reporting Software Used:\n" - print prog + print PROG print "===================== CLIP HERE ============================" print print "(do not include below in ARRL submission)" @@ -1987,7 +1987,7 @@ def contestlog(pr): print "Participant List" print l = [] - for i in participants.values(): + for i in PARTICIPANTS.values(): l.append(i) l.sort() n = 0 @@ -2016,35 +2016,35 @@ def contestlog(pr): print print "Worked All States during FD Status" print - r = qdb.wasrpt() + r = QDB.wasrpt() for i in r: print i print print print "Detailed Log" print - print " Date Range", gd.getv('fdstrt'), "-", gd.getv('fdend'), "UTC" + print " Date Range", GD.getv('fdstrt'), "-", GD.getv('fdend'), "UTC" print - qdb.prlog() + QDB.prlog() print print print "ADIF Log" print - qdb.pradif() + QDB.pradif() print print "VHF Cabrillo" print - qdb.vhf_cabrillo() + QDB.vhf_cabrillo() print print print "Winter Field day" print - qdb.winter_fd() + QDB.winter_fd() print print "eof" sys.stdout = sys.__stdout__ # revert print to console print - print "entry and log written to file", logfile + print "entry and log written to file", LOGFILE # setup for phonetics printout ## to get phonetics on bottom of gui? # d = {"a":"alpha ","b":"bravo ","c":"charlie ","d":"delta ","e":"echo ", \ @@ -2064,26 +2064,26 @@ def contestlog(pr): # band set buttons # this can be customized -Only here customizing this in program will break from compatibility with # original fdlog.py -bands = ('160', '80', '40', '20', '15', '10', '6', '2', '220', '440', '900', '1200', 'sat', 'off') -modes = ('c', 'd', 'p') -bandb = {} # band button handles +BANDS = ('160', '80', '40', '20', '15', '10', '6', '2', '220', '440', '900', '1200', 'sat', 'off') +MODES = ('c', 'd', 'p') +BANDB = {} # band button handles def bandset(b): - global band, tmob - if node == "": + global BAND, TMOB + if NODE == "": b = 'off' - txtbillb.insert(END, "err - no node\n") - if operator == "": + TXTBILLB.insert(END, "err - no node\n") + if OPERATOR == "": b = 'off' - txtbillb.insert(END, "err - no Operator\n") + TXTBILLB.insert(END, "err - no Operator\n") if b != 'off': - s = net.si.nod_on_band(b) - if s: txtbillb.insert(END, " Already on [%s]: %s\n" % (b, s)) - txtbillb.see(END) - if band != b: tmob = now() # reset time on band - band = b - bandb[b].select() + s = NET.si.nod_on_band(b) + if s: TXTBILLB.insert(END, " Already on [%s]: %s\n" % (b, s)) + TXTBILLB.see(END) + if BAND != b: TMOB = now() # reset time on band + BAND = b + BANDB[b].select() renew_title() def bandoff(): @@ -2096,37 +2096,37 @@ class NewParticipantDialog(): """ this is the new participant window that pops up""" def dialog(self): - if node == "": - txtbillb.insert(END, "err - no node\n") + if NODE == "": + TXTBILLB.insert(END, "err - no node\n") return s = NewParticipantDialog() - s.t = Toplevel(root) - s.t.transient(root) + s.t = Toplevel(ROOT) + s.t.transient(ROOT) s.t.title('Add New Participant') fr1 = Frame(s.t) fr1.grid(row=0, column=0) - Label(fr1, text='Initials ', font=fdbfont).grid(row=0, column=0, sticky=W) - s.initials = Entry(fr1, width=3, font=fdbfont, validate='focusout', validatecommand=s.lookup) + Label(fr1, text='Initials ', font=FDBFONT).grid(row=0, column=0, sticky=W) + s.initials = Entry(fr1, width=3, font=FDBFONT, validate='focusout', validatecommand=s.lookup) s.initials.grid(row=0, column=1, sticky=W) s.initials.focus() - Label(fr1, text='Name', font=fdbfont).grid(row=1, column=0, sticky=W) - s.name = Entry(fr1, width=20, font=fdbfont) + Label(fr1, text='Name', font=FDBFONT).grid(row=1, column=0, sticky=W) + s.name = Entry(fr1, width=20, font=FDBFONT) s.name.grid(row=1, column=1, sticky=W) - Label(fr1, text='Call', font=fdbfont).grid(row=2, column=0, sticky=W) - s.call = Entry(fr1, width=6, font=fdbfont) + Label(fr1, text='Call', font=FDBFONT).grid(row=2, column=0, sticky=W) + s.call = Entry(fr1, width=6, font=FDBFONT) s.call.grid(row=2, column=1, sticky=W) - Label(fr1, text='Age', font=fdbfont).grid(row=3, column=0, sticky=W) - s.age = Entry(fr1, width=2, font=fdbfont) + Label(fr1, text='Age', font=FDBFONT).grid(row=3, column=0, sticky=W) + s.age = Entry(fr1, width=2, font=FDBFONT) s.age.grid(row=3, column=1, sticky=W) - Label(fr1, text='Visitor Title', font=fdbfont).grid(row=4, column=0, sticky=W) - s.vist = Entry(fr1, width=20, font=fdbfont) + Label(fr1, text='Visitor Title', font=FDBFONT).grid(row=4, column=0, sticky=W) + s.vist = Entry(fr1, width=20, font=FDBFONT) s.vist.grid(row=4, column=1, sticky=W) fr2 = Frame(s.t) fr2.grid(row=1, column=0, sticky=EW, pady=3) fr2.grid_columnconfigure((0, 1), weight=1) - Label(fr2, text='=Save', font=fdbfont, foreground='red').grid(row=3, column=0, sticky=W) + Label(fr2, text='=Save', font=FDBFONT, foreground='red').grid(row=3, column=0, sticky=W) #Button(fr2, text='Save', font=fdbfont, command=s.applybtn) .grid(row=3, column=1, sticky=EW, padx=3) - Button(fr2, text='Dismiss', font=fdbfont, command=s.quitbtn) .grid(row=3, column=2, sticky=EW, padx=3) + Button(fr2, text='Dismiss', font=FDBFONT, command=s.quitbtn) .grid(row=3, column=2, sticky=EW, padx=3) # Bound enter key to save entries s.t.bind('', lambda event: s.applybtn) @@ -2139,7 +2139,7 @@ def lookup(self): self.initials.focus() else: self.initials.configure(bg='white') - dummy, name, call, age, vist = string.split(participants.get(initials, ', , , , '), ', ') + dummy, name, call, age, vist = string.split(PARTICIPANTS.get(initials, ', , , , '), ', ') self.name.delete(0, END) self.name.insert(END, name) self.call.delete(0, END) @@ -2158,7 +2158,7 @@ def lookup(self): @property #This added so I can use the binding def applybtn(self): - global participants + global PARTICIPANTS # print "store" initials = self.initials.get().lower() name = self.name.get() @@ -2171,32 +2171,32 @@ def applybtn(self): self.age.configure(bg='white') self.vist.configure(bg='white') if not re.match(r'[a-zA-Z]{2,3}$', initials): - txtbillb.insert(END, "error in initials\n") - txtbillb.see(END) + TXTBILLB.insert(END, "error in initials\n") + TXTBILLB.see(END) topper() self.initials.focus() self.initials.configure(bg='gold') elif not re.match(r'[A-Za-z ]{4,20}$', name): - txtbillb.insert(END, "error in name\n") - txtbillb.see(END) + TXTBILLB.insert(END, "error in name\n") + TXTBILLB.see(END) topper() self.name.focus() self.name.configure(bg='gold') elif not re.match(r'([a-zA-Z0-9]{3,6})?$', call): - txtbillb.insert(END, "error in call\n") - txtbillb.see(END) + TXTBILLB.insert(END, "error in call\n") + TXTBILLB.see(END) topper() self.call.focus() self.call.configure(bg='gold') elif not re.match(r'([0-9]{1,2})?$', age): - txtbillb.insert(END, "error in age\n") - txtbillb.see(END) + TXTBILLB.insert(END, "error in age\n") + TXTBILLB.see(END) topper() self.age.focus() self.age.configure(bg='gold') elif not re.match(r'([a-zA-Z0-9]{4,20})?$', vist): - txtbillb.insert(END, "error in title\n") - txtbillb.see(END) + TXTBILLB.insert(END, "error in title\n") + TXTBILLB.see(END) topper() self.vist.focus() self.vist.configure(bg='gold') @@ -2205,11 +2205,11 @@ def applybtn(self): initials nam = "p:%s" % initials v = "%s, %s, %s, %s, %s" % (initials, name, call, age, vist) - participants[initials] = v - dummy = qdb.globalshare(nam, v) # store + bcast - txtbillb.insert(END, "\a New Participant Entered.") + PARTICIPANTS[initials] = v + dummy = QDB.globalshare(nam, v) # store + bcast + TXTBILLB.insert(END, "\a New Participant Entered.") print "\a" - txtbillb.see(END) + TXTBILLB.see(END) topper() self.initials.delete(0, END) self.name.delete(0, END) @@ -2223,82 +2223,82 @@ def quitbtn(self): self.t.destroy() -newpart = NewParticipantDialog() +NEWPART = NewParticipantDialog() # property dialogs -cf = {} +CF = {} def renew_title(): """renew title and various, called at 10 second rate""" - if node == 'gotanode': - call = string.upper(gd.getv('gcall')) + if NODE == 'gotanode': + call = string.upper(GD.getv('gcall')) else: - call = string.upper(gd.getv('fdcall')) - clas = string.upper(gd.getv('class')) - sec = gd.getv('sect') + call = string.upper(GD.getv('fdcall')) + clas = string.upper(GD.getv('class')) + sec = GD.getv('sect') t = now() - sob = tmsub(t, tmob) + sob = tmsub(t, TMOB) mob = sob / 60 h = mob / 60 m = mob % 60 # Added port to the heading - root.title(' FDLOG %s %s %s (Node: %s Time on Band: %d:%02d) %s:%s UTC %s/%s Port:%s' % \ - (call, clas, sec, node, h, m, t[-6:-4], t[-4:-2], t[2:4], t[4:6], port_base)) - net.bcast_now() # this is periodic bcast... + ROOT.title(' FDLOG %s %s %s (Node: %s Time on Band: %d:%02d) %s:%s UTC %s/%s Port:%s' % \ + (call, clas, sec, NODE, h, m, t[-6:-4], t[-4:-2], t[2:4], t[4:6], PORT_BASE)) + NET.bcast_now() # this is periodic bcast... def setnode(new): - global node + global NODE bandoff() - node = string.lower(new) - qdb.redup() + NODE = string.lower(new) + QDB.redup() renew_title() - lblnode.configure(text="My Node: %s" % node, font=fdfont, foreground='royalblue', background='lightgrey') + LBLNODE.configure(text="My Node: %s" % NODE, font=FDFONT, foreground='royalblue', background='lightgrey') # Had to add the above so that the new lblnode could be updated def applyprop(e=''): """apply property""" - global operator, logger, power, node - new = cf['e'].get() - if re.match(cf['vre'], new): + global OPERATOR, LOGGER, POWER, NODE + new = CF['e'].get() + if re.match(CF['vre'], new): # if cf['lab'] == 'Operator': operator = new # elif cf['lab'] == 'Logger': logger = new # elif cf['lab'] == 'Power': power = new - if cf['lab'] == 'Node': + if CF['lab'] == 'Node': setnode(new) # elif cf['lab'] == 'AuthKey': reauth(new) #net.setauth(new) else: print 'error, no such var' saveglob() renew_title() - cf['p'].destroy() + CF['p'].destroy() else: print 'bad syntax', new def pdiag(label, value, valid_re, wid): "property dialog box" - cf['p'] = Toplevel(root) - cf['p'].transient(root) - Label(cf['p'], text=label, font=fdbfont).grid(sticky=E, pady=20) + CF['p'] = Toplevel(ROOT) + CF['p'].transient(ROOT) + Label(CF['p'], text=label, font=FDBFONT).grid(sticky=E, pady=20) if label == 'AuthKey': - cf['e'] = Entry(cf['p'], width=wid, font=fdbfont, show='*') + CF['e'] = Entry(CF['p'], width=wid, font=FDBFONT, show='*') else: - cf['e'] = Entry(cf['p'], width=wid, font=fdbfont) - cf['e'].grid(row=0, column=1, sticky=W) - cf['e'].insert(END, value) - Button(cf['p'], text="Apply", command=applyprop, font=fdbfont) \ + CF['e'] = Entry(CF['p'], width=wid, font=FDBFONT) + CF['e'].grid(row=0, column=1, sticky=W) + CF['e'].insert(END, value) + Button(CF['p'], text="Apply", command=applyprop, font=FDBFONT) \ .grid(sticky=W, padx=20) - Button(cf['p'], text="Cancel", command=cf['p'].destroy, font=fdbfont) \ + Button(CF['p'], text="Cancel", command=CF['p'].destroy, font=FDBFONT) \ .grid(padx=20, pady=20, row=1, column=1, sticky=E) - cf['vre'] = valid_re - cf['lab'] = label - cf['e'].bind('', applyprop) - cf['p'].bind('', lambda e: (cf['p'].destroy())) - cf['e'].focus() + CF['vre'] = valid_re + CF['lab'] = label + CF['e'].bind('', applyprop) + CF['p'].bind('', lambda e: (CF['p'].destroy())) + CF['e'].focus() def noddiag(): - pdiag('Node', node, r'[A-Za-z0-9-]{1,8}$', 8) + pdiag('Node', NODE, r'[A-Za-z0-9-]{1,8}$', 8) #def authdiag(): # pdiag('AuthKey',authk,r'.{3,12}$',12) @@ -2307,10 +2307,10 @@ def noddiag(): def viewprep(ttl=''): "view preparation core code" - w = Toplevel(root) + w = Toplevel(ROOT) ## w.transient(root) w.title("FDLOG - %s" % ttl) - t = Text(w, takefocus=0, height=20, width=85, font=fdfont, \ + t = Text(w, takefocus=0, height=20, width=85, font=FDFONT, \ wrap=NONE, setgrid=1) s = Scrollbar(w, command=t.yview) t.configure(yscrollcommand=s.set) @@ -2351,17 +2351,17 @@ def viewtextf(fn, ttl=''): def viewlogf(bandm): "view log filtered by bandmode" - lg = qdb.filterlog2(bandm) + lg = QDB.filterlog2(bandm) viewtextl(lg, "Log Filtered for %s" % bandm) def viewlogfs(nod): "view log filtered by node" - lg = qdb.filterlogst(nod) + lg = QDB.filterlogst(nod) viewtextl(lg, "Log Filtered for %s" % nod) def viewwasrpt(): - r = qdb.wasrpt() + r = QDB.wasrpt() viewtextl(r, "Worked All States Report") @@ -2369,56 +2369,56 @@ def updatebb(): """update band buttons""" # Added Who's on the bands functionality with a mouse over event # Tried and tried to get wof to return only one result for the mouse over. If you can, you're awesome! - global wof - r, cl, vh, go = net.si.nod_on_bands() + global WOF + r, cl, vh, go = NET.si.nod_on_bands() anytext = "VHF " def whosonfirst(event): # Cleaned up whos on band (with section of .ba report) d = {} - txtbillb.insert(END,"\n--node-- band opr lgr pwr ----- last\n") - for t in net.si.nodinfo.values(): + TXTBILLB.insert(END, "\n--node-- band opr lgr pwr ----- last\n") + for t in NET.si.nodinfo.values(): dummy, dummy, age = d.get(t.nod, ('', '', 9999)) if age > t.age: d[t.nod] = (t.bnd, t.msc, t.age) for t in d: - txtbillb.insert(END,"%8s %4s %-18s %4s\n" % (t, d[t][0], d[t][1], d[t][2])) # t.bnd,t.msc,t.age) + TXTBILLB.insert(END, "%8s %4s %-18s %4s\n" % (t, d[t][0], d[t][1], d[t][2])) # t.bnd,t.msc,t.age) topper() - txtbillb.see(END) + TXTBILLB.see(END) def whosonsecond(event): - global wof - wof = "" + global WOF + WOF = "" #tkMessageBox.destroy - for i in bands: + for i in BANDS: dummy = 0 - for j in modes: + for j in MODES: bm = "%s%s" % (i, j) if i == 'off': continue bc = 'lightgray' sc = 'white' n = len(r.get(bm, '')) - bandb[bm].bind("", lambda e: None) - bandb[bm].bind("", lambda e: None) + BANDB[bm].bind("", lambda e: None) + BANDB[bm].bind("", lambda e: None) if n == 0: bc = 'lightgrey' - bandb[bm].bind("", lambda e: None) - bandb[bm].bind("", lambda e: None) + BANDB[bm].bind("", lambda e: None) + BANDB[bm].bind("", lambda e: None) elif n == 1: bc = 'gold' - bandb[bm].bind("", whosonfirst) - bandb[bm].bind("", whosonsecond) + BANDB[bm].bind("", whosonfirst) + BANDB[bm].bind("", whosonsecond) else: bc = 'darkorange'; sc = 'red' - bandb[bm].bind("", whosonfirst) - bandb[bm].bind("", whosonsecond) - bandb[bm].configure(background=bc, selectcolor=sc) + BANDB[bm].bind("", whosonfirst) + BANDB[bm].bind("", whosonsecond) + BANDB[bm].configure(background=bc, selectcolor=sc) - cltg = ival(gd.getv('class')) # class target + cltg = ival(GD.getv('class')) # class target if cltg > 1: vhfree = 1 # handle free vhf xmttr ts = cl - vhfree @@ -2438,7 +2438,7 @@ def whosonsecond(event): clc = 'palegreen' if ts > cltg: clc = 'pink2' - bandb['Class'].configure(text='Class %s/%s' % (ts, cltg), background=clc) + BANDB['Class'].configure(text='Class %s/%s' % (ts, cltg), background=clc) vhc = 'gold' if vh - vhfree == 0: @@ -2450,7 +2450,7 @@ def whosonsecond(event): if vh > vhfree: vhc = 'darkorange' # 2 vhf is okay, only 1 is free... anytext = "VHF taking HF " - bandb['VHF'].configure(text='%s%s/%s' % (anytext, vh, vhfree), background=vhc) + BANDB['VHF'].configure(text='%s%s/%s' % (anytext, vh, vhfree), background=vhc) if cltg > 1: gotatg = 1 @@ -2459,103 +2459,103 @@ def whosonsecond(event): goc = 'gold' if go == gotatg: goc = 'palegreen' if go > gotatg: goc = 'pink2' - bandb['GOTA'].configure(text='GOTA %s/%s' % (go, gotatg), background=goc) + BANDB['GOTA'].configure(text='GOTA %s/%s' % (go, gotatg), background=goc) def updateqct(): "update contact count" dummy, dummy, qpop, qplg, dummy, dummy, dummy, dummy, cwq, digq, fonq, dummy, gotaq, dummy, dummy = \ - qdb.bandrpt() # xx reduce processing here + QDB.bandrpt() # xx reduce processing here for i, j in (('FonQ', 'Phone %5s' % fonq), ('CW/D', 'CW&Dig %4s' % (cwq + digq)), ('GOTAq', 'GOTA %6s' % gotaq)): - bandb[i].configure(text=j, background='lightgrey') + BANDB[i].configure(text=j, background='lightgrey') # Update for the operator OpQ - for fd 2014 - if operator == "": + if OPERATOR == "": coin2 = "Operator" - opmb.config(text=coin2, background='pink2') - opds.config(text="", background='pink2') else: - coin = exin(operator) + coin = exin(OPERATOR) if coin in qpop: coin2 = qpop['%s' % coin] - opmb.config(text='ConQ %2s' % coin2, background='lightgrey') - opds.config(text=operator, background='lightgrey') + OPMB.config(text='ConQ %2s' % coin2, background='lightgrey') + OPDS.config(text=OPERATOR, background='lightgrey') else: coin2 = "0" - opmb.config(text='ConQ %2s' % coin2, background='lightgrey') - opds.config(text=operator, background='lightgrey') + OPMB.config(text='ConQ %2s' % coin2, background='lightgrey') + OPDS.config(text=OPERATOR, background='lightgrey') # Update for the logger LoQ - for fd 2014 - if logger == "": + if LOGGER == "": coil2 = "Logger" - logmb.config(text=coil2, background='pink2') - logds.config(text="", background='pink2') else: - coil = exin(logger) + coil = exin(LOGGER) if coil in qplg: coil2 = qplg['%s' % coil] - logmb.config(text='LogQ %2s' % coil2, background='lightgrey') - logds.config(text=logger, background='lightgrey') + LOGMB.config(text='LogQ %2s' % coil2, background='lightgrey') + LOGDS.config(text=LOGGER, background='lightgrey') else: coil2 = "0" - logmb.config(text='LogQ %2s' % coil2, background='lightgrey') - logds.config(text=logger, background='lightgrey') + LOGMB.config(text='LogQ %2s' % coil2, background='lightgrey') + LOGDS.config(text=LOGGER, background='lightgrey') t = "" # check for net config trouble - if net.fills: t = "NEED FILL" - if net.badauth_rcvd: - net.badauth_rcvd = 0 + if NET.fills: t = "NEED FILL" + if NET.badauth_rcvd: + NET.badauth_rcvd = 0 t = "AUTH FAIL" - if net.pkts_rcvd: - net.pkts_rcvd = 0 + if NET.pkts_rcvd: + NET.pkts_rcvd = 0 else: t = "Alone? Not receiving data from others. Firewall?" - if net.send_errs: - t = "SEND FAIL - Not sending data to others. Firewall?"; net.send_errs = 0 - if authk == '': + if NET.send_errs: + t = "SEND FAIL - Not sending data to others. Firewall?"; NET.send_errs = 0 + if AUTHK == '': t = "NO AUTHKEY SELECTED" - if node == '': + if NODE == '': t = "NO NODE SELECTED" if t: - lblnet.configure(text=t, background='gold') + LBLNET.configure(text=t, background='gold') else: - lblnet.configure(text="Network OK", background='lightgrey') + LBLNET.configure(text="Network OK", background='lightgrey') def BandButtons(w): "create band buttons" - global sv + global SV a = 0 - sv = StringVar() - sv.set(band) + SV = StringVar() + SV.set(BAND) mac = os.name == 'posix' # detect the mac added 152i - for i in bands: + for i in BANDS: b = 0 - for j in modes: + for j in MODES: bm = "%s%s" % (i, j) if i == 'off': bm = 'off' # indicatoron = 0 makes square button with text inside but doesn't work well on mac, with value 1 it makes a # circle alongside the text and works on both so detect mac and change it for mac only - bandb[bm] = Radiobutton(master=w, text=bm, font=fdfont, background='lightgrey', indicatoron=mac, \ - variable=sv, value=bm, selectcolor='pink2', + BANDB[bm] = Radiobutton(master=w, text=bm, font=FDFONT, background='lightgrey', indicatoron=mac, \ + variable=SV, value=bm, selectcolor='pink2', command=lambda b=bm: (bandset(b))) else: - bandb[bm] = Radiobutton(master=w, text=bm, font=fdfont, background='pink2', indicatoron=mac, \ - variable=sv, value=bm, selectcolor='white', + BANDB[bm] = Radiobutton(master=w, text=bm, font=FDFONT, background='pink2', indicatoron=mac, \ + variable=SV, value=bm, selectcolor='white', command=lambda b=bm: (bandset(b))) - bandb[bm].grid(row=b, column=a, sticky=NSEW) + BANDB[bm].grid(row=b, column=a, sticky=NSEW) b += 1 a += 1 for i, j, dummy in (('Class', 0, 5), ('VHF', 1, 13), ('GOTA', 2, 9)): - bandb[i] = Button(w, text=i, font=fdfont) - bandb[i].grid(row=j, column=a, sticky=NSEW) + BANDB[i] = Button(w, text=i, font=FDFONT) + BANDB[i].grid(row=j, column=a, sticky=NSEW) w.grid_columnconfigure(a, weight=1) a += 1 for i, j in (('FonQ', 0), ('CW/D', 1), ('GOTAq', 2)): - bandb[i] = Button(w, text=i, font=fdfont) - bandb[i].grid(row=j, column=a, sticky=NSEW) + BANDB[i] = Button(w, text=i, font=FDFONT) + BANDB[i].grid(row=j, column=a, sticky=NSEW) w.grid_columnconfigure(a, weight=1) @@ -2570,44 +2570,44 @@ def rnddig(): def testqgen(n): # added if authk protection so that .testqgen only operates with a 'tst' database. # no funny business with the contest log - if authk == "tst": + if AUTHK == "tst": while n: call = rndlet() + rndlet() + rnddig() + rndlet() + rndlet() + rndlet() rpt = rnddig() + rndlet() + ' ' + rndlet() + rndlet() + ' testQ' print call, rpt n -= 1 - qdb.qsl(now(), call, band, rpt) + QDB.qsl(now(), call, BAND, rpt) time.sleep(0.1) else: - txtbillb.insert(END, "This command only available while testing with tst.") + TXTBILLB.insert(END, "This command only available while testing with tst.") # global section, main program # setup persistent globals before GUI -suffix = "" -call = "" -band = "off" -power = "0" -operator = "" -logger = "" -age = 0 -vist = "" -node = "" -authk = "" -port_base = 7373 -tmob = now() # time started on band in min -tdwin = 10 # time diff window on displaying node clock diffs -showbc = 0 # show broadcasts -debug = 0 -logdbf = "fdlog.fdd" # persistent file copy of log database -logfile = "fdlog.log" # printable log file (contest entry) -globf = "fdlog.dat" # persistent global file -kbuf = "" # keyboard line buffer -goBack = "" # needed to print the last line entered with up arrow +SUFFIX = "" +CALL = "" +BAND = "off" +POWER = "0" +OPERATOR = "" +LOGGER = "" +AGE = 0 +VIST = "" +NODE = "" +AUTHK = "" +PORT_BASE = 7373 +TMOB = now() # time started on band in min +TDWIN = 10 # time diff window on displaying node clock diffs +SHOWBC = 0 # show broadcasts +DEBUG = 0 +LOGDBF = "fdlog.fdd" # persistent file copy of log database +LOGFILE = "fdlog.log" # printable log file (contest entry) +GLOBF = "fdlog.dat" # persistent global file +KBUF = "" # keyboard line buffer +GOBACK = "" # needed to print the last line entered with up arrow loadglob() # load persistent globals from file print -if node == "": +if NODE == "": # Revised for 8 characters so the log lines up nicely print " Enter the station name" print " Please be 7 characters! (I will add letters to be unique)" @@ -2618,123 +2618,123 @@ def testqgen(n): if len(k) == 8: print "That's too many.. (Marc? is that you?)" # Thanks to Marc Fountain K9MAF for the correction. k = k[:7] - z = len(k) + Z = len(k) if k != 'gota': - while z != 7: + while Z != 7: if k == 'gota': print "please restart the program." sys.exit() else: - if z < 4: + if Z < 4: print "um yeah.. 7 characters.... (restart if your gota)" k = string.lower(string.strip(sys.stdin.readline())[:8]) - z = len(k) + Z = len(k) else: - for z in range(z, 7): + for Z in range(Z, 7): print "close enough (Ken? is that you?)" k = k + random.choice('abcdefghijklmnopqrstuvwxyz') print k - z = len(k) + Z = len(k) ## 1. if there is more than four characters ## 2. add the rest with randoms else: print "Thank You!!" - node = k + random.choice('abcdefghijklmnopqrstuvwxyz') + NODE = k + random.choice('abcdefghijklmnopqrstuvwxyz') print else: print "Thank You for being gota!!" - node = 'gotanode' + NODE = 'gotanode' print -print "Using Node ID: '%s' " % node +print "Using Node ID: '%s' " % NODE print # get auth key auth xxxpppzzz.. fdlogxxx.fdd port ppp hashkey (all) # allow user to select new one, or re-use previous -print "Enter Authentication Key (Return to re-use previous '%s')" % authk +print "Enter Authentication Key (Return to re-use previous '%s')" % AUTHK print " (use 'tst' for testing, two digit year for contest):" k = string.strip(sys.stdin.readline()) if k != "": print "New Key entered, Operator and Logger cleared" - authk = k - operator = "" - logger = "" + AUTHK = k + OPERATOR = "" + LOGGER = "" print -print "Using Authentication Key: '%s'" % authk -print "Using", authk[0:3], "for setting port, file" -port_offset = ival(authk[3:6]) * 7 -if port_offset == 0: port_offset = ival(authk[0:3]) * 7 +print "Using Authentication Key: '%s'" % AUTHK +print "Using", AUTHK[0:3], "for setting port, file" +PORT_OFFSET = ival(AUTHK[3:6]) * 7 +if PORT_OFFSET == 0: PORT_OFFSET = ival(AUTHK[0:3]) * 7 # for each char in port_offset: xxx # port_offset = ((port_offset << 3) + (char & 15)) & 0x0fff -port_base += port_offset -print "Using Network Port:", port_base -logdbf = "fdlog%s.fdd" % (authk[0:3]) -print "Writing Log Journal file:", logdbf +PORT_BASE += PORT_OFFSET +print "Using Network Port:", PORT_BASE +LOGDBF = "fdlog%s.fdd" % (AUTHK[0:3]) +print "Writing Log Journal file:", LOGDBF print "Starting Network" -net = netsync() # setup net -net.setport(port_base) -net.setauth(authk) -print "Saving Persistent Configuration in", globf +NET = netsync() # setup net +NET.setport(PORT_BASE) +NET.setauth(AUTHK) +print "Saving Persistent Configuration in", GLOBF saveglob() -print "Time Difference Window (tdwin):", tdwin, "seconds" +print "Time Difference Window (tdwin):", TDWIN, "seconds" print "Starting GUI setup" -root = Tk() # setup Tk GUI +ROOT = Tk() # setup Tk GUI # root.withdraw() # This was removed in the last beta without explanation -menu = Menu(root) -root.config(menu=menu) -filemenu = Menu(menu, tearoff=0) -menu.add_cascade(label="File", menu=filemenu) -filemenu.add_command(label="Save Entry File", command=lambda: contestlog(1)) -filemenu.add_command(label="PreView Saved Entry File", +MENU = Menu(ROOT) +ROOT.config(menu=MENU) +FILEMENU = Menu(MENU, tearoff=0) +MENU.add_cascade(label="File", menu=FILEMENU) +FILEMENU.add_command(label="Save Entry File", command=lambda: contestlog(1)) +FILEMENU.add_command(label="PreView Saved Entry File", command=lambda: viewtextf('fdlog.log')) -filemenu.add_command(label="View Log Data File", - command=lambda: viewtextf(logdbf)) -filemenu.add_command(label="Exit", command=root.quit) -propmenu = Menu(menu, tearoff=0) -menu.add_cascade(label="Properties", menu=propmenu) -propmenu.add_command(label="Set Node ID", command=noddiag) -propmenu.add_command(label="Add Participants", command=newpart.dialog) -logmenu = Menu(menu, tearoff=0) -menu.add_cascade(label="Logs", menu=logmenu) -logmenu.add_command(label='Full Log', command=lambda: viewlogf("")) -logmenu.add_command(label='QSTs', command=lambda: viewlogf(r"[*]QST")) -logmenu.add_command(label='GOTA', command=lambda: viewlogfs("gota")) -logmenu.add_command(label='WAS', command=viewwasrpt) -for j in modes: - m = Menu(logmenu, tearoff=0) +FILEMENU.add_command(label="View Log Data File", + command=lambda: viewtextf(LOGDBF)) +FILEMENU.add_command(label="Exit", command=ROOT.quit) +PROPMENU = Menu(MENU, tearoff=0) +MENU.add_cascade(label="Properties", menu=PROPMENU) +PROPMENU.add_command(label="Set Node ID", command=noddiag) +PROPMENU.add_command(label="Add Participants", command=NEWPART.dialog) +LOGMENU = Menu(MENU, tearoff=0) +MENU.add_cascade(label="Logs", menu=LOGMENU) +LOGMENU.add_command(label='Full Log', command=lambda: viewlogf("")) +LOGMENU.add_command(label='QSTs', command=lambda: viewlogf(r"[*]QST")) +LOGMENU.add_command(label='GOTA', command=lambda: viewlogfs("gota")) +LOGMENU.add_command(label='WAS', command=viewwasrpt) +for j in MODES: + m = Menu(LOGMENU, tearoff=0) if j == 'c': lab = 'CW' elif j == 'd': lab = 'Digital' elif j == 'p': lab = 'Phone' - logmenu.add_cascade(label=lab, menu=m) - for i in bands: + LOGMENU.add_cascade(label=lab, menu=m) + for i in BANDS: if i == 'off': continue bm = "%s%s" % (i, j) m.add_command(label=bm, command=lambda x=bm: (viewlogf(x))) # Added Resources Menu Item to clean up the menu -resourcemenu = Menu(menu, tearoff=0) -menu.add_cascade(label="Resources", menu=resourcemenu) +RESOURCEMENU = Menu(MENU, tearoff=0) +MENU.add_cascade(label="Resources", menu=RESOURCEMENU) # Changed this from fdrules to just Rules to get away from fd name in file folder -resourcemenu.add_command(label="ARRL FD Rules (pdf)", command=lambda: os.startfile('Rules.pdf')) +RESOURCEMENU.add_command(label="ARRL FD Rules (pdf)", command=lambda: os.startfile('Rules.pdf')) # Changed this to a .dat file to remove the duplicate txt file -resourcemenu.add_command(label="ARRL Sections", command=lambda: viewtextf('Arrl_sect.dat', 'ARRL Sections')) -resourcemenu.add_command(label="ARRL Band Chart (pdf)", command=lambda: os.startfile('Bands.pdf')) -resourcemenu.add_command(label="ARRL Band Plan", command=lambda: viewtextf('ARRL_Band_Plans.txt', "ARRL Band Plan")) +RESOURCEMENU.add_command(label="ARRL Sections", command=lambda: viewtextf('Arrl_sect.dat', 'ARRL Sections')) +RESOURCEMENU.add_command(label="ARRL Band Chart (pdf)", command=lambda: os.startfile('Bands.pdf')) +RESOURCEMENU.add_command(label="ARRL Band Plan", command=lambda: viewtextf('ARRL_Band_Plans.txt', "ARRL Band Plan")) # This is not needed with the band chart giving the same info #resourcemenu.add_command(label="FD Frequency List", command=lambda: viewtextf('frequencies.txt', "FD Frequency List")) # Removed the propagation report. We don't use it #resourcemenu.add_command(label="Propagation Info", command=lambda: viewtextf('propagation.txt', "Propagation Info")) # Created a W1AW menu -W1AWmenu = Menu(menu, tearoff=0) -menu.add_cascade(label="W1AW", menu=W1AWmenu) -W1AWmenu.add_command(label="W1AW Schedule", command=lambda: viewtextf('w1aw.txt', 'W1AW Schedule')) -W1AWmenu.add_command(label="NTS Message", command=lambda: os.startfile('NTS_eg.txt')) +W1AWMENU = Menu(MENU, tearoff=0) +MENU.add_cascade(label="W1AW", menu=W1AWMENU) +W1AWMENU.add_command(label="W1AW Schedule", command=lambda: viewtextf('w1aw.txt', 'W1AW Schedule')) +W1AWMENU.add_command(label="NTS Message", command=lambda: os.startfile('NTS_eg.txt')) # Time Conversion Chart -tzchart = """ +TZCHART = """ UTC PDT CDT EDT GMT PST CST EST """ @@ -2747,65 +2747,65 @@ def testqgen(n): if (e < 0): e += 2400 x = e + 100 if (x < 0): x += 2400 - tzchart += "%04d %04d %04d %04d %04d\n" % (g, p, c, e, x) -resourcemenu.add_command(label="Time Conversion Chart", command=lambda: viewtextv(tzchart, "Time Conversion Chart")) -helpmenu = Menu(menu, tearoff=0) -menu.add_cascade(label="Help", menu=helpmenu) -helpmenu.add_command(label="Quick Help", command=lambda: viewtextf('Keyhelp.txt')) -helpmenu.add_command(label="Set Commands", command=gd.sethelp) -helpmenu.add_command(label="The Manual", command=lambda: viewtextf('Manual.txt', "Manual")) -helpmenu.add_command(label="Release Log", command=lambda: viewtextf('Releaselog.txt')) -helpmenu.add_command(label="GitHub ReadMe", command=lambda: viewtextf('readme.txt')) -helpmenu.add_command(label="About FDLOG", command=lambda: viewtextv(about, "About")) + TZCHART += "%04d %04d %04d %04d %04d\n" % (g, p, c, e, x) +RESOURCEMENU.add_command(label="Time Conversion Chart", command=lambda: viewtextv(TZCHART, "Time Conversion Chart")) +HELPMENU = Menu(MENU, tearoff=0) +MENU.add_cascade(label="Help", menu=HELPMENU) +HELPMENU.add_command(label="Quick Help", command=lambda: viewtextf('Keyhelp.txt')) +HELPMENU.add_command(label="Set Commands", command=GD.sethelp) +HELPMENU.add_command(label="The Manual", command=lambda: viewtextf('Manual.txt', "Manual")) +HELPMENU.add_command(label="Release Log", command=lambda: viewtextf('Releaselog.txt')) +HELPMENU.add_command(label="GitHub ReadMe", command=lambda: viewtextf('readme.txt')) +HELPMENU.add_command(label="About FDLOG", command=lambda: viewtextv(ABOUT, "About")) # Band Buttons -f1 = Frame(root, bd=1) -BandButtons(f1) -f1.grid(row=0, columnspan=2, sticky=NSEW) +F1 = Frame(ROOT, bd=1) +BandButtons(F1) +F1.grid(row=0, columnspan=2, sticky=NSEW) def testcmd(name, rex, value): """set global from command, return value and change status""" - global kbuf + global KBUF value = default # added in 152i s = "%s +(%s)$" % (name, rex) - m = re.match(s, kbuf) + m = re.match(s, KBUF) if m: value = m.group(1) - txtbillb.insert(END, "\n%s set to %s\n" % (name, value)) - kbuf = "" + TXTBILLB.insert(END, "\n%s set to %s\n" % (name, value)) + KBUF = "" return value, default != value def setoper(op): "set operator" - global operator + global OPERATOR # print "setoper",op ini, name, call, age, vist = string.split(op, ', ') - operator = "%s: %s, %s, %s, %s" % (ini, name, call, age, vist) + OPERATOR = "%s: %s, %s, %s, %s" % (ini, name, call, age, vist) # Adding red to the display ocolor = 'lightgrey' - opds.config(text=operator, background=ocolor) - opmb.config(background='gold') + OPDS.config(text=OPERATOR, background=ocolor) + OPMB.config(background='gold') saveglob() def setlog(logr): """set logger""" - global logger + global LOGGER # print "setlog",logr ini, name, call, age, vist = string.split(logr, ', ') - logger = "%s: %s, %s, %s, %s" % (ini, name, call, age, vist) + LOGGER = "%s: %s, %s, %s, %s" % (ini, name, call, age, vist) lcolor = 'lightgrey' - logds.config(text=logger, background=lcolor) - logmb.config(background='gold') + LOGDS.config(text=LOGGER, background=lcolor) + LOGMB.config(background='gold') saveglob() -f1b = Frame(root, bd=0) # oper logger power and network windows +F1B = Frame(ROOT, bd=0) # oper logger power and network windows # Changed the color of the user buttons to red until assigned -ocolor = 'pink2' -lcolor = 'pink2' -pcolor = 'pink2' +OCOLOR = 'pink2' +LCOLOR = 'pink2' +PCOLOR = 'pink2' # Add "who" button to display messagebox with operators on band when clicked. # Determined that this is not needed now that the mouse over report is cleaner. #opwho = Menubutton(f1b, text='WHO ', font=fdfont, relief='raised', @@ -2813,158 +2813,158 @@ def setlog(logr): #opwho.grid(row=0, column=0, sticky=NSEW) # Operator -opmb = Menubutton(f1b,text='Operator',font=fdfont,relief='raised', background=ocolor) -opmb.grid(row=0,column=1,sticky=NSEW) -opmu = Menu(opmb,tearoff=0) -opmb.config(menu=opmu,direction='below') -opmu.add_command(label="Add New Operator",command=newpart.dialog) -opds = Menubutton(f1b, text='', font=FDFONT, relief='raised', background=OCOLOR) +OPDS.grid(row=0, column=0, sticky=NSEW) +OPDSU = Menu(OPDS, tearoff=0) +OPDS.config(menu=OPDSU, direction='below') +F1B.grid_columnconfigure(0, weight=1) # Logger -logmb = Menubutton(f1b,text="Logger",font=fdfont,relief='raised',background=lcolor) -logmb.grid(row=0,column=4,sticky=NSEW) -logmu = Menu(logmb,tearoff=0) -logmb.config(menu=logmu,direction='below') -logmu.add_command(label="Add New Logger",command=newpart.dialog) -logds = Menubutton(f1b,text='', font=FDFONT, relief='raised', background=LCOLOR) +LOGDS.grid(row=0, column=3, sticky=NSEW) +F1B.grid_columnconfigure(3, weight=1) +LOGDSU = Menu(LOGDS, tearoff=0) +LOGDS.config(menu=LOGDSU, direction='below') +LOGDSU.add_command(label="Add New Logger", command=NEWPART.dialog) def buildmenus(): - opdsu.delete(0, END) - logdsu.delete(0, END) - l = participants.values() + OPDSU.delete(0, END) + LOGDSU.delete(0, END) + l = PARTICIPANTS.values() l.sort() for i in l: # had to take out the $ which looks for the end of value # Decided non-hams can be in operator field but will check for license before logging # m = re.match(r'[a-z0-9]+, [a-zA-Z ]+, ([a-z0-9]+)',i) #if m: opdsu.add_command(label=i, command=lambda n=i: (setoper(n))) - opdsu.add_command(label=i, command=lambda n=i: (setoper(n))) - logdsu.add_command(label=i, command=lambda n=i: (setlog(n))) - opdsu.add_command(label="Add New Operator", command=newpart.dialog) - logdsu.add_command(label="Add New Logger", command=newpart.dialog) + OPDSU.add_command(label=i, command=lambda n=i: (setoper(n))) + LOGDSU.add_command(label=i, command=lambda n=i: (setlog(n))) + OPDSU.add_command(label="Add New Operator", command=NEWPART.dialog) + LOGDSU.add_command(label="Add New Logger", command=NEWPART.dialog) # power def ckpowr(): - global power - pwr = ival(pwrnt.get()) + global POWER + pwr = ival(PWRNT.get()) if pwr < 0: pwr = "0" elif pwr > 1500: pwr = "1500" - pwrnt.delete(0, END) - pwrnt.insert(END, pwr) - if natv.get(): + PWRNT.delete(0, END) + PWRNT.insert(END, pwr) + if NATV.get(): pwr = "%sn" % pwr else: pwr = "%s" % pwr - power = pwr - if power == "0": + POWER = pwr + if POWER == "0": pcolor = 'pink2' - pwrmb.config(background=pcolor) - pwrnt.config(background=pcolor) - powcb.config(background=pcolor) - powlbl.config(background=pcolor) + PWRMB.config(background=pcolor) + PWRNT.config(background=pcolor) + POWCB.config(background=pcolor) + POWLBL.config(background=pcolor) else: pcolor = 'lightgray' - pwrmb.config(background=pcolor) - pwrnt.config(background=pcolor) - powcb.config(background=pcolor) - powlbl.config(background=pcolor) - if power == "0n": + PWRMB.config(background=pcolor) + PWRNT.config(background=pcolor) + POWCB.config(background=pcolor) + POWLBL.config(background=pcolor) + if POWER == "0n": pcolor = 'pink2' - pwrmb.config(background=pcolor) - pwrnt.config(background=pcolor) - powcb.config(background=pcolor) - powlbl.config(background=pcolor) + PWRMB.config(background=pcolor) + PWRNT.config(background=pcolor) + POWCB.config(background=pcolor) + POWLBL.config(background=pcolor) else: pcolor == 'lightgray' - pwrmb.config(background=pcolor) - pwrnt.config(background=pcolor) - powcb.config(background=pcolor) - powlbl.config(background=pcolor) - print 'power', power + PWRMB.config(background=pcolor) + PWRNT.config(background=pcolor) + POWCB.config(background=pcolor) + POWLBL.config(background=pcolor) + print 'power', POWER return 1 def setpwr(p): - global power + global POWER pwr = ival(p) - pwrnt.delete(0, END) - pwrnt.insert(END, pwr) + PWRNT.delete(0, END) + PWRNT.insert(END, pwr) if p[-1:] == 'n': - powcb.select() + POWCB.select() else: - powcb.deselect() - power = p - if power == "0": + POWCB.deselect() + POWER = p + if POWER == "0": pcolor = 'pink2' - pwrmb.config(background=pcolor) - pwrnt.config(background=pcolor) - powcb.config(background=pcolor) - powlbl.config(background=pcolor) + PWRMB.config(background=pcolor) + PWRNT.config(background=pcolor) + POWCB.config(background=pcolor) + POWLBL.config(background=pcolor) else: pcolor = 'lightgray' - pwrmb.config(background=pcolor) - pwrnt.config(background=pcolor) - powcb.config(background=pcolor) - powlbl.config(background=pcolor) - if power == "0n": + PWRMB.config(background=pcolor) + PWRNT.config(background=pcolor) + POWCB.config(background=pcolor) + POWLBL.config(background=pcolor) + if POWER == "0n": pcolor = 'pink2' - pwrmb.config(background=pcolor) - pwrnt.config(background=pcolor) - powcb.config(background=pcolor) - powlbl.config(background=pcolor) + PWRMB.config(background=pcolor) + PWRNT.config(background=pcolor) + POWCB.config(background=pcolor) + POWLBL.config(background=pcolor) else: pcolor == 'lightgray' - pwrmb.config(background=pcolor) - pwrnt.config(background=pcolor) - powcb.config(background=pcolor) - powlbl.config(background=pcolor) + PWRMB.config(background=pcolor) + PWRNT.config(background=pcolor) + POWCB.config(background=pcolor) + POWLBL.config(background=pcolor) -pwrmb = Menubutton(f1b, text="Power", font=fdfont, relief='raised', - background=pcolor) -pwrmb.grid(row=0, column=6, sticky=NSEW) -pwrmu = Menu(pwrmb, tearoff=0) -pwrmb.config(menu=pwrmu, direction='below') -pwrmu.add_command(label=' 0 Watts', command=lambda: (setpwr('0'))) -pwrmu.add_command(label=' 5 Watts', command=lambda: (setpwr('5'))) -pwrmu.add_command(label=' 50 Watts', command=lambda: (setpwr('50'))) -pwrmu.add_command(label=' 100 Watts', command=lambda: (setpwr('100'))) -pwrmu.add_command(label=' 150 Watts', command=lambda: (setpwr('150'))) -pwrmu.add_command(label=' 200 Watts', command=lambda: (setpwr('200'))) -pwrmu.add_command(label=' 500 Watts', command=lambda: (setpwr('500'))) -pwrmu.add_command(label='1000 Watts', command=lambda: (setpwr('1000'))) -pwrmu.add_command(label='1500 Watts', command=lambda: (setpwr('1500'))) -pwrmu.add_command(label=' 5W Natural', command=lambda: (setpwr('5n'))) -pwrmu.add_command(label=' 50W Natural', command=lambda: (setpwr('50n'))) -pwrmu.add_command(label=' 100W Natural', command=lambda: (setpwr('100n'))) -pwrmu.add_command(label=' 150W Natural', command=lambda: (setpwr('150n'))) -pwrnt = Entry(f1b, width=4, font=fdfont, background=pcolor, validate='focusout', validatecommand=ckpowr) -pwrnt.grid(row=0, column=7, sticky=NSEW) -powlbl = Label(f1b, text="W", font=fdfont, background=pcolor) -powlbl.grid(row=0, column=8, sticky=NSEW) -natv = IntVar() -powcb = Checkbutton(f1b, text="Natural", variable=natv, command=ckpowr, - font=fdfont, relief='raised', background=pcolor) -powcb.grid(row=0, column=9, sticky=NSEW) -setpwr(power) -f1b.grid(row=1, columnspan=2, sticky=NSEW) +PWRMB = Menubutton(F1B, text="Power", font=FDFONT, relief='raised', + background=PCOLOR) +PWRMB.grid(row=0, column=6, sticky=NSEW) +PWRMU = Menu(PWRMB, tearoff=0) +PWRMB.config(menu=PWRMU, direction='below') +PWRMU.add_command(label=' 0 Watts', command=lambda: (setpwr('0'))) +PWRMU.add_command(label=' 5 Watts', command=lambda: (setpwr('5'))) +PWRMU.add_command(label=' 50 Watts', command=lambda: (setpwr('50'))) +PWRMU.add_command(label=' 100 Watts', command=lambda: (setpwr('100'))) +PWRMU.add_command(label=' 150 Watts', command=lambda: (setpwr('150'))) +PWRMU.add_command(label=' 200 Watts', command=lambda: (setpwr('200'))) +PWRMU.add_command(label=' 500 Watts', command=lambda: (setpwr('500'))) +PWRMU.add_command(label='1000 Watts', command=lambda: (setpwr('1000'))) +PWRMU.add_command(label='1500 Watts', command=lambda: (setpwr('1500'))) +PWRMU.add_command(label=' 5W Natural', command=lambda: (setpwr('5n'))) +PWRMU.add_command(label=' 50W Natural', command=lambda: (setpwr('50n'))) +PWRMU.add_command(label=' 100W Natural', command=lambda: (setpwr('100n'))) +PWRMU.add_command(label=' 150W Natural', command=lambda: (setpwr('150n'))) +PWRNT = Entry(F1B, width=4, font=FDFONT, background=PCOLOR, validate='focusout', validatecommand=ckpowr) +PWRNT.grid(row=0, column=7, sticky=NSEW) +POWLBL = Label(F1B, text="W", font=FDFONT, background=PCOLOR) +POWLBL.grid(row=0, column=8, sticky=NSEW) +NATV = IntVar() +POWCB = Checkbutton(F1B, text="Natural", variable=NATV, command=ckpowr, + font=FDFONT, relief='raised', background=PCOLOR) +POWCB.grid(row=0, column=9, sticky=NSEW) +setpwr(POWER) +F1B.grid(row=1, columnspan=2, sticky=NSEW) # Network window -lblnet = Label(f1b, text="Network Status", font=fdfont, foreground='royalblue', background='gold') -lblnet.grid(row=2, column=0, columnspan=9, sticky=NSEW) +LBLNET = Label(F1B, text="Network Status", font=FDFONT, foreground='royalblue', background='gold') +LBLNET.grid(row=2, column=0, columnspan=9, sticky=NSEW) # Node window -lblnode = Label(f1b, text="My Node: %s" % node, font=fdfont, foreground='royalblue', background='lightgrey') -lblnode.grid(row=2, column=9, columnspan=1, sticky=NSEW) +LBLNODE = Label(F1B, text="My Node: %s" % NODE, font=FDFONT, foreground='royalblue', background='lightgrey') +LBLNODE.grid(row=2, column=9, columnspan=1, sticky=NSEW) # Whos on First Window to display operators on bands # lblwof = Label(f1b, text="", font=fdfont, foreground='royalblue', background='lightgrey') # lblwof.grid(row=2, column=0, columnspan=9, sticky=NSEW) @@ -2972,28 +2972,28 @@ def setpwr(p): # lblport = Label(f1b, text="Port: %s" % port_base, font=fdfont, foreground='royalblue', background='lightgrey') # lblport.grid(row=3, column=9, columnspan=1, sticky=NSEW) # log window -logw = Text(root, takefocus=0, height=11, width=80, font=fdmfont, +LOGW = Text(ROOT, takefocus=0, height=11, width=80, font=FDMFONT, background='lightgrey', wrap=NONE, setgrid=1) # logw.configure(cursor='arrow') -scroll = Scrollbar(root, command=logw.yview, background='lightgrey') -logw.configure(yscrollcommand=scroll.set) -logw.grid(row=2, column=0, sticky=NSEW) -scroll.grid(row=2, column=1, sticky=NS) -root.grid_rowconfigure(2, weight=1) -root.grid_columnconfigure(0, weight=1) +SCROLL = Scrollbar(ROOT, command=LOGW.yview, background='lightgrey') +LOGW.configure(yscrollcommand=SCROLL.set) +LOGW.grid(row=2, column=0, sticky=NSEW) +SCROLL.grid(row=2, column=1, sticky=NS) +ROOT.grid_rowconfigure(2, weight=1) +ROOT.grid_columnconfigure(0, weight=1) # txtbillb = dialog window -txtbillb = Text(root, takefocus=1, height=10, width=80, font=fdmfont, +TXTBILLB = Text(ROOT, takefocus=1, height=10, width=80, font=FDMFONT, wrap=NONE, setgrid=1, background='lightgrey') -scrollt = Scrollbar(root, command=txtbillb.yview) -txtbillb.configure(yscrollcommand=scrollt.set) -txtbillb.grid(row=3, column=0, sticky=NSEW) -scrollt.grid(row=3, column=1, sticky=NS) -root.grid_rowconfigure(3, weight=1) -logw.tag_config("b", foreground="royalblue") -logw.insert(END, " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", ("b")) -logw.insert(END, " DATABASE DISPLAY WINDOW\n", ("b")) -logw.insert(END, " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", ("b")) -logw.insert(END, "%s\n" % prog, ("b")) +SCROLLT = Scrollbar(ROOT, command=TXTBILLB.yview) +TXTBILLB.configure(yscrollcommand=SCROLLT.set) +TXTBILLB.grid(row=3, column=0, sticky=NSEW) +SCROLLT.grid(row=3, column=1, sticky=NS) +ROOT.grid_rowconfigure(3, weight=1) +LOGW.tag_config("b", foreground="royalblue") +LOGW.insert(END, " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", ("b")) +LOGW.insert(END, " DATABASE DISPLAY WINDOW\n", ("b")) +LOGW.insert(END, " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", ("b")) +LOGW.insert(END, "%s\n" % PROG, ("b")) # Add a bottom window for station information # f1c = Frame(root, bd=1) # f1c.grid(row=4,columnspan=4,sticky=NSEW) @@ -3018,12 +3018,12 @@ def setpwr(p): # startup contestlog(0) # define globals buildmenus() -sms = syncmsg() # setup sync message service -qdb = qsodb() # init qso database -qdb.loadfile() # read log file +SMS = syncmsg() # setup sync message service +QDB = qsodb() # init qso database +QDB.loadfile() # read log file print "Showing GUI" print -if node == gd.getv('tmast'): +if NODE == GD.getv('tmast'): print "This Node is the TIME MASTER!!" print "THIS COMPUTER'S CLOCK BETTER BE RIGHT (preferably GPS locked)" print "User should Insure that system time is within 1 second of the" @@ -3036,23 +3036,23 @@ def setpwr(p): print # These root commands were removed without an explanation in the beta. # but will leave them in. -root.update() -root.deiconify() -net.start() # start threads +ROOT.update() +ROOT.deiconify() +NET.start() # start threads renew_title() -txtbillb.insert(END, " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", ("b")) -txtbillb.insert(END, " Dialogue Window\n", ("b")) -txtbillb.insert(END, " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n", ("b")) -txtbillb.insert(END, "Please select the Operator, Logger, Power and Band/Mode in pink above.\n\n") -txtbillb.insert(END, "-Call-Class-Sect- \n") -txtbillb.config(insertwidth=3) -txtbillb.focus_set() +TXTBILLB.insert(END, " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", ("b")) +TXTBILLB.insert(END, " Dialogue Window\n", ("b")) +TXTBILLB.insert(END, " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n", ("b")) +TXTBILLB.insert(END, "Please select the Operator, Logger, Power and Band/Mode in pink above.\n\n") +TXTBILLB.insert(END, "-Call-Class-Sect- \n") +TXTBILLB.config(insertwidth=3) +TXTBILLB.focus_set() def topper(): """This will reset the display for input""" - txtbillb.insert(END, "\n") - txtbillb.insert(END, "-Call-Class-Sect- \n") + TXTBILLB.insert(END, "\n") + TXTBILLB.insert(END, "-Call-Class-Sect- \n") def showthiscall(call): @@ -3060,14 +3060,14 @@ def showthiscall(call): p = call.split('/') # print p[0] findany = 0 - m, dummy, dummy = qdb.cleanlog() + m, dummy, dummy = QDB.cleanlog() # print m.values() for i in m.values(): # print i.call q = i.call.split('/') if p[0] == q[0]: - if findany == 0: txtbillb.insert(END, "\n") - txtbillb.insert(END, "%s\n" % i.prlogln(i)) + if findany == 0: TXTBILLB.insert(END, "\n") + TXTBILLB.insert(END, "%s\n" % i.prlogln(i)) findany = 1 return findany @@ -3076,7 +3076,7 @@ def showthiscall(call): def mhelp(): viewtextf('Keyhelp.txt') -secName = {} +SECNAME = {} def readSections(): """this will read the Arrl_sect.dat file for sections""" @@ -3089,7 +3089,7 @@ def readSections(): if ln[0] == '#': continue try: sec, dummy, dummy, dummy = string.split(ln,None,3) - secName[sec] = sec + SECNAME[sec] = sec except ValueError,e: print "rd arrl sec dat err, itm skpd: ",e fd.close() @@ -3101,26 +3101,26 @@ def readSections(): def proc_key(ch): "process keystroke" - global kbuf, power, operator, logger, debug, band, node, suffix, tdwin, goBack # timeok + global KBUF, POWER, OPERATOR, LOGGER, DEBUG, BAND, NODE, SUFFIX, TDWIN, GOBACK # timeok testq = 0 - if ch == '?' and (kbuf == "" or kbuf[0] != '#'): # ? for help + if ch == '?' and (KBUF == "" or KBUF[0] != '#'): # ? for help mhelp() return # Adding a statement to check for uppercase. Previously unresponsive while capped locked # Thanks to WW9A Brian Smith for pointing out that the program isn't randomly frozen and not requiring a restart. if ch.isupper(): - txtbillb.insert(END, " LOWERCAPS PLEASE \n") - kbuf = "" + TXTBILLB.insert(END, " LOWERCAPS PLEASE \n") + KBUF = "" topper() return if ch == '\r': # return, may be cmd or log entry - if kbuf[:1] == '#': - qdb.qst(kbuf[1:]) - kbuf = "" - txtbillb.insert(END, '\n') + if KBUF[:1] == '#': + QDB.qst(KBUF[1:]) + KBUF = "" + TXTBILLB.insert(END, '\n') return # check for valid commands - if re.match(r'[.]h$', kbuf): # help request + if re.match(r'[.]h$', KBUF): # help request m = """ .band 160/80/40/20/15/10/6/2/220/440/900/1200/sat c/d/p .off change band to off @@ -3133,107 +3133,107 @@ def proc_key(ch): .ba station band report .pr generate entry and log files""" viewtextv(m, 'Command Help') - kbuf = "" - txtbillb.insert(END, '\n') + KBUF = "" + TXTBILLB.insert(END, '\n') return - pwr, s = testcmd(".pow", r"[0-9]{1,4}n?", power) + pwr, s = testcmd(".pow", r"[0-9]{1,4}n?", POWER) if s is True: - power = pwr - setpwr(power) + POWER = pwr + setpwr(POWER) netsync.rem_host, s = testcmd('.remip', r'([0-9]{1,3}[.]){3}[0-9]{1,3}', netsync.rem_host) - if s: globDb.put('remip', netsync.rem_host) + if s: GLOBDB.put('remip', netsync.rem_host) # This change was made below for debug, tdwin, and testq - v, s = testcmd(".debug", r"[0-9]+", debug) - if s is True: debug = int(v) - v, s = testcmd(".tdwin", r"[0-9]{1,3}", tdwin) - if s is True: tdwin = int(v) + v, s = testcmd(".debug", r"[0-9]+", DEBUG) + if s is True: DEBUG = int(v) + v, s = testcmd(".tdwin", r"[0-9]{1,3}", TDWIN) + if s is True: TDWIN = int(v) v, s = testcmd(".testq", r"[0-9]{1,2}", testq) if s is True: testq = int(v) if testq: testqgen(testq) saveglob() renew_title() - m = re.match(r"[.]set ([a-z0-9]{3,6}) (.*)$", kbuf) + m = re.match(r"[.]set ([a-z0-9]{3,6}) (.*)$", KBUF) if m: name, val = m.group(1, 2) - r = gd.setv(name, val, now()) + r = GD.setv(name, val, now()) if r: - txtbillb.insert(END, "\n%s\n" % r) + TXTBILLB.insert(END, "\n%s\n" % r) else: - txtbillb.insert(END, "\n") - qdb.globalshare(name, val) # global to db - kbuf = "" + TXTBILLB.insert(END, "\n") + QDB.globalshare(name, val) # global to db + KBUF = "" renew_title() return - m = re.match(r"[.]band (((160|80|40|20|15|10|6|2|220|440|900|1200|sat)[cdp])|off)", kbuf) + m = re.match(r"[.]band (((160|80|40|20|15|10|6|2|220|440|900|1200|sat)[cdp])|off)", KBUF) if m: print nb = m.group(1) - kbuf = "" - txtbillb.insert(END, "\n") + KBUF = "" + TXTBILLB.insert(END, "\n") bandset(nb) return - if re.match(r'[.]off$', kbuf): + if re.match(r'[.]off$', KBUF): bandoff() - kbuf = "" - txtbillb.insert(END, "\n") + KBUF = "" + TXTBILLB.insert(END, "\n") return - if re.match(r'[.]ba$', kbuf): - qdb.bands() - kbuf = "" - txtbillb.insert(END, "\n") + if re.match(r'[.]ba$', KBUF): + QDB.bands() + KBUF = "" + TXTBILLB.insert(END, "\n") return - if re.match(r'[.]pr$', kbuf): + if re.match(r'[.]pr$', KBUF): contestlog(1) - txtbillb.insert(END, " Entry/Log File Written\n") - txtbillb.insert(END, "\n") - kbuf = "" + TXTBILLB.insert(END, " Entry/Log File Written\n") + TXTBILLB.insert(END, "\n") + KBUF = "" return p = r'[.]edit ([a-z0-9]{1,6})' - if re.match(p, kbuf): - m = re.match(p, kbuf) + if re.match(p, KBUF): + m = re.match(p, KBUF) call = m.group(1) # qdb.delete(nod,seq,reason) - kbuf = "" - txtbillb.insert(END, "To edit: click on the log entry\n") + KBUF = "" + TXTBILLB.insert(END, "To edit: click on the log entry\n") return #Found that .node needed fixing. Reworked - if re.match(r'[.]node', kbuf): - if band != 'off': - txtbillb.insert(END, "\nSet band off before changing node id\n") - kbuf = "" + if re.match(r'[.]node', KBUF): + if BAND != 'off': + TXTBILLB.insert(END, "\nSet band off before changing node id\n") + KBUF = "" return else: - nde, s = testcmd(".node", r"[a-z0-9-]{1,8}", node) + nde, s = testcmd(".node", r"[a-z0-9-]{1,8}", NODE) if s is True: - node = nde - setnode(node) - kbuf = "" - txtbillb.insert(END, "\n") + NODE = nde + setnode(NODE) + KBUF = "" + TXTBILLB.insert(END, "\n") topper() return - if re.match(r'[.]st$', kbuf): # status xx mv to gui + if re.match(r'[.]st$', KBUF): # status xx mv to gui print print - print "FD Call %s" % string.upper(gd.getv('fdcall')) - print "GOTA Call %s" % string.upper(gd.getv('gcall')) - print "FD Report %s %s" % (string.upper(gd.getv('class')), gd.getv('sect')) - print "Band %s" % band - print "Power %s" % power - print "Operator %s" % operator - print "Logger %s" % logger - print "Node %s" % node - if authk != "" and node != "": + print "FD Call %s" % string.upper(GD.getv('fdcall')) + print "GOTA Call %s" % string.upper(GD.getv('gcall')) + print "FD Report %s %s" % (string.upper(GD.getv('class')), GD.getv('sect')) + print "Band %s" % BAND + print "Power %s" % POWER + print "Operator %s" % OPERATOR + print "Logger %s" % LOGGER + print "Node %s" % NODE + if AUTHK != "" and NODE != "": print "Net enabled" else: print "Net disabled" print - kbuf = "" - txtbillb.insert(END, "\n") + KBUF = "" + TXTBILLB.insert(END, "\n") return - if re.match(r'[.]re$', kbuf): # report xx mv to gui + if re.match(r'[.]re$', KBUF): # report xx mv to gui print print " band cw q pwr dig q pwr fon q pwr" - qpb, ppb, dummy, dummy, dummy, tq, score, maxp, dummy, dummy, dummy, dummy, dummy, dummy, dummy = qdb.bandrpt() + qpb, ppb, dummy, dummy, dummy, tq, score, maxp, dummy, dummy, dummy, dummy, dummy, dummy, dummy = QDB.bandrpt() for b in (160, 80, 40, 20, 15, 10, 6, 2, 220, 440, 1200, 'sat', 'gota'): print "%6s" % b, for m in 'cdp': @@ -3243,36 +3243,36 @@ def proc_key(ch): print print "%s total Qs, %s QSO points," % (tq, score), print maxp, "watts maximum power" - kbuf = "" - txtbillb.insert(END, "\n") + KBUF = "" + TXTBILLB.insert(END, "\n") topper() return - if kbuf and kbuf[0] == '.': # detect invalid command - txtbillb.insert(END, " Invalid Command\n") - kbuf = "" - txtbillb.insert(END, "\n") + if KBUF and KBUF[0] == '.': # detect invalid command + TXTBILLB.insert(END, " Invalid Command\n") + KBUF = "" + TXTBILLB.insert(END, "\n") topper() return # check for valid contact if (ch == '\r'): - stat, ftm, dummy, sfx, call, xcall, rept = qdb.qparse(kbuf) - goBack = "%s %s" % (call, rept)# for the up arrow enhancement + stat, ftm, dummy, sfx, call, xcall, rept = QDB.qparse(KBUF) + GOBACK = "%s %s" % (call, rept)# for the up arrow enhancement if stat == 5: # whole qso parsed - kbuf = "" - if len(node) < 3: - txtbillb.insert(END, " ERROR, set .node before logging\n") + KBUF = "" + if len(NODE) < 3: + TXTBILLB.insert(END, " ERROR, set .node before logging\n") topper() - elif qdb.dupck(xcall, band): # dup check - txtbillb.insert(END, "\n\n ***DUPE*** on band %s ***DUPE***\n" % band) + elif QDB.dupck(xcall, BAND): # dup check + TXTBILLB.insert(END, "\n\n ***DUPE*** on band %s ***DUPE***\n" % BAND) topper() - elif qdb.partck(xcall): # Participant check - txtbillb.insert(END, "\n Participant - not allowed \n") + elif QDB.partck(xcall): # Participant check + TXTBILLB.insert(END, "\n Participant - not allowed \n") topper() - elif xcall == string.lower(gd.getv('fdcall')): - txtbillb.insert(END, "\n That's us - not allowed \n") + elif xcall == string.lower(GD.getv('fdcall')): + TXTBILLB.insert(END, "\n That's us - not allowed \n") topper() - elif xcall == string.lower(gd.getv('gcall')): - txtbillb.insert(END, "\n That's us - not allowed \n") + elif xcall == string.lower(GD.getv('gcall')): + TXTBILLB.insert(END, "\n That's us - not allowed \n") topper() else: # Added database protection against no band, no power, @@ -3281,44 +3281,44 @@ def proc_key(ch): # logged but not counting points # Checking Operator or Logger has a license legal = 0 - if re.match(r'[a-z :]+ [a-zA-Z ]+, ([a-z0-9]+)',operator): + if re.match(r'[a-z :]+ [a-zA-Z ]+, ([a-z0-9]+)', OPERATOR): #print "%s has a license" % operator legal = legal + 1 - if re.match(r'[a-z :]+ [a-zA-Z ]+, ([a-z0-9]+)',logger): + if re.match(r'[a-z :]+ [a-zA-Z ]+, ([a-z0-9]+)', LOGGER): #print "%s has a license" % logger legal = legal + 1 if legal == 0: - txtbillb.insert(END, "\n\n The Operator or the logger needs a license.\n") - txtbillb.insert(END, " Please Try Again\n") + TXTBILLB.insert(END, "\n\n The Operator or the logger needs a license.\n") + TXTBILLB.insert(END, " Please Try Again\n") topper() return # checking for band, power, operator or logger em = '' - if band == "off": em += " Band " - if power == 0: em += " Power " - if len(operator) < 2: em += " Operator " - if len(logger) < 2: em += " Logger " + if BAND == "off": em += " Band " + if POWER == 0: em += " Power " + if len(OPERATOR) < 2: em += " Operator " + if len(LOGGER) < 2: em += " Logger " if em != '': - txtbillb.insert(END, " - WARNING: ( %s ) NOT SET" % em) - txtbillb.insert(END, " Please Try Again\n") + TXTBILLB.insert(END, " - WARNING: ( %s ) NOT SET" % em) + TXTBILLB.insert(END, " Please Try Again\n") topper() return if em == '': # This checks 1D to 1D contacts - clas = string.upper(gd.getv('class')) + clas = string.upper(GD.getv('class')) rept1 = string.upper(rept) if clas == '1D': if clas in rept1: - txtbillb.insert(END, "\n 1D to 1D contacts are logged, but zero points! \n") + TXTBILLB.insert(END, "\n 1D to 1D contacts are logged, but zero points! \n") topper() # check the report for valid fd or wfd classes: # note according to the cheat sheet, \d is a digit reptclass, dummy = rept.split(" ") m = "" - if gd.getv('contst') == "fd": + if GD.getv('contst') == "fd": # field day, report in: #+a-f m = re.match(r'[\d][a-fA-F]', rept) - elif gd.getv('contst') == "wfd": + elif GD.getv('contst') == "wfd": # WFD m = re.match(r'[\d][ihoIHO]', rept) else: @@ -3326,7 +3326,7 @@ def proc_key(ch): # allow everything m = "something" if m == None: # match failed, do not allow and abort logging - txtbillb.insert(END, " - ERROR: Bad exchange ( %s ) Please Try Again\n" % rept) + TXTBILLB.insert(END, " - ERROR: Bad exchange ( %s ) Please Try Again\n" % rept) topper() return # Check for valid section in report @@ -3334,14 +3334,14 @@ def proc_key(ch): #print "aaaaa is %s" % aaaaa rept2 = rept1[3:aaaaa].strip() #print "rept2 is %s" % rept2 - if rept2 in secName: + if rept2 in SECNAME: pass else: print "\n Use one of these for the section:" kk = "" nx = 0 ny = 0 - for k in sorted(secName): + for k in sorted(SECNAME): if ny == 0: kk += "\n " ny = ny + 1 @@ -3354,99 +3354,99 @@ def proc_key(ch): nx = 0 print kk #print('\n'.join("{} : {}".format(k, v) for k, v in secName.items())) - txtbillb.insert(END, kk) - txtbillb.insert(END, "\n Please try one of the sections above.") + TXTBILLB.insert(END, kk) + TXTBILLB.insert(END, "\n Please try one of the sections above.") topper() return # The entry is good and ready to log - txtbillb.insert(END, " - QSL! May I have another?") - txtbillb.insert(END, "\n") + TXTBILLB.insert(END, " - QSL! May I have another?") + TXTBILLB.insert(END, "\n") topper() tm = now() if ftm: # force timestamp tm = tm[0:4] + ftm[0:8] + tm[11:] # yymmdd.hhmmss - qdb.qsl(tm, xcall, band, rept) + QDB.qsl(tm, xcall, BAND, rept) elif stat == 4: - kbuf = "" + KBUF = "" # Added participant check here too - if qdb.partck(xcall): # Participant check - txtbillb.insert(END, "\n Participant - not allowed \n") + if QDB.partck(xcall): # Participant check + TXTBILLB.insert(END, "\n Participant - not allowed \n") topper() elif showthiscall(call) == 0: - txtbillb.insert(END, " none found\n") + TXTBILLB.insert(END, " none found\n") topper() return if ch == '\x1b': # escape quits this input line - txtbillb.insert(END, " ESC -aborted line-\n") + TXTBILLB.insert(END, " ESC -aborted line-\n") topper() - kbuf = "" + KBUF = "" return if ch == '\b': # backspace erases char - if kbuf != "": - kbuf = kbuf[0:-1] - txtbillb.delete('end - 2 chars') + if KBUF != "": + KBUF = KBUF[0:-1] + TXTBILLB.delete('end - 2 chars') return if ch == '\u1p': # up arrow reprints the input line - if goBack != "": - if kbuf == "": - txtbillb.insert(END, goBack) #print goBack info - kbuf = goBack + if GOBACK != "": + if KBUF == "": + TXTBILLB.insert(END, GOBACK) #print goBack info + KBUF = GOBACK else: return else: - kbuf = "" + KBUF = "" return if ch == ' ': # space, check for prefix/suffix/call - stat, tm, dummy, sfx, call, xcall, rept = qdb.qparse(kbuf) + stat, tm, dummy, sfx, call, xcall, rept = QDB.qparse(KBUF) if stat == 2: # suffix, dup check - suffix = kbuf - kbuf = "" - r = qdb.sfx2call(suffix, band) + SUFFIX = KBUF + KBUF = "" + r = QDB.sfx2call(SUFFIX, BAND) if not r: r = 'None' - txtbillb.insert(END, ": %s on band '%s'\n" % (r, band)) + TXTBILLB.insert(END, ": %s on band '%s'\n" % (r, BAND)) return if stat == 3: # prefix, combine w suffix - stat, tm, dummy, sfx, call, xcall, rept = qdb.qparse(kbuf + suffix) + stat, tm, dummy, sfx, call, xcall, rept = QDB.qparse(KBUF + SUFFIX) if stat == 4: # whole call - kbuf += suffix - txtbillb.insert(END, sfx) # fall into call dup ck + KBUF += SUFFIX + TXTBILLB.insert(END, sfx) # fall into call dup ck if stat == 4: # whole call, dup chk - if qdb.dupck(xcall, band): - txtbillb.insert(END, "\n\n ***DUPE*** on band %s ***DUPE***" % band) + if QDB.dupck(xcall, BAND): + TXTBILLB.insert(END, "\n\n ***DUPE*** on band %s ***DUPE***" % BAND) showthiscall(call) - kbuf = "" + KBUF = "" topper() - elif qdb.partck(xcall): # Participant check - txtbillb.insert(END, "\n Participant - not allowed \n") + elif QDB.partck(xcall): # Participant check + TXTBILLB.insert(END, "\n Participant - not allowed \n") showthiscall(call) - kbuf = "" + KBUF = "" topper() else: - kbuf += ' ' - txtbillb.insert(END, ch) + KBUF += ' ' + TXTBILLB.insert(END, ch) if showthiscall(call): # shows the previous contacts with this station - txtbillb.insert(END, "%s " % xcall) + TXTBILLB.insert(END, "%s " % xcall) return - buf = kbuf + ch # echo & add legal char to kbd buf + buf = KBUF + ch # echo & add legal char to kbd buf if len(buf) < 50: if buf[0] == '.': if re.match(r'[ a-zA-Z0-9.,/@-]{0,45}$', ch): - kbuf = buf - txtbillb.insert(END, ch) + KBUF = buf + TXTBILLB.insert(END, ch) elif buf[0] == '#': if re.match(r'#[ a-zA-Z0-9.,?/!@$;:+=%&()-]{0,40}$', buf): - kbuf = buf - txtbillb.insert(END, ch) + KBUF = buf + TXTBILLB.insert(END, ch) else: - stat, tm, dummy, sfx, call, xcall, rept = qdb.qparse(buf) + stat, tm, dummy, sfx, call, xcall, rept = QDB.qparse(buf) if stat > 0 and len(buf) < 50: - kbuf = buf - txtbillb.insert(END, ch) + KBUF = buf + TXTBILLB.insert(END, ch) def kevent(event): "keyboard event handler" - global goBack + global GOBACK # print "event '%s' '%s' '%s'"%(event.type,event.keysym,event.keysym_num) k = event.keysym_num if 31 < k < 123: # space to z @@ -3459,12 +3459,12 @@ def kevent(event): proc_key('\x1b') elif k == 65293: # return proc_key('\r') - txtbillb.see(END) # Ensure that it stays in view + TXTBILLB.see(END) # Ensure that it stays in view return "break" # prevent further processing on kbd events def focevent(e): - txtbillb.mark_set('insert', END) + TXTBILLB.mark_set('insert', END) return "break" @@ -3472,8 +3472,8 @@ class Edit_Dialog(Toplevel): """edit log entry dialog""" """Added functionality to check for dupes and change the title to show the error""" # Had to add variables for each text box to know if they changed to do dupe check. - global editedornot - editedornot = StringVar + global EDITEDORNOT + EDITEDORNOT = StringVar crazytxt = StringVar() crazytxt.set('Edit Log Entry') crazyclr = StringVar() @@ -3483,69 +3483,69 @@ class Edit_Dialog(Toplevel): def __init__(self, parent, node, seq): s = '%s.%s' % (node, seq) self.node, self.seq = node, seq - if qdb.byid[s].band[0] == '*': return + if QDB.byid[s].band[0] == '*': return top = self.top = Toplevel(parent) # Toplevel.__init__(self,parent) # self.transient(parent) # avoid showing as separate item self.crazytxt.set('Edit Log Entry') self.crazyclr.set('lightgrey') - self.crazylbl = tl = Label(top, text=self.crazytxt.get(), font=fdbfont, bg=self.crazyclr.get(), relief=RAISED) + self.crazylbl = tl = Label(top, text=self.crazytxt.get(), font=FDBFONT, bg=self.crazyclr.get(), relief=RAISED) # tl = Label(top, text='Edit Log Entry', font=fdbfont, bg='lightgrey', relief=RAISED) tl.grid(row=0, columnspan=2, sticky=EW) tl.grid_columnconfigure(0, weight=1) - Label(top, text='Date', font=fdbfont).grid(row=1, sticky=W) + Label(top, text='Date', font=FDBFONT).grid(row=1, sticky=W) # Label(top,text='Time',font=fdbfont).grid(row=2,sticky=W) - Label(top, text='Band', font=fdbfont).grid(row=3, sticky=W) + Label(top, text='Band', font=FDBFONT).grid(row=3, sticky=W) # Label(top,text='Mode',font=fdbfont).grid(row=4,sticky=W) - Label(top, text='Call', font=fdbfont).grid(row=5, sticky=W) - Label(top, text='Report', font=fdbfont).grid(row=6, sticky=W) - Label(top, text='Power', font=fdbfont).grid(row=7, sticky=W) + Label(top, text='Call', font=FDBFONT).grid(row=5, sticky=W) + Label(top, text='Report', font=FDBFONT).grid(row=6, sticky=W) + Label(top, text='Power', font=FDBFONT).grid(row=7, sticky=W) # Label(top,text='Natural',font=fdbfont).grid(row=8,sticky=W) - Label(top, text='Operator', font=fdbfont).grid(row=9, sticky=W) - Label(top, text='Logger', font=fdbfont).grid(row=10, sticky=W) - self.de = Entry(top, width=13, font=fdbfont) + Label(top, text='Operator', font=FDBFONT).grid(row=9, sticky=W) + Label(top, text='Logger', font=FDBFONT).grid(row=10, sticky=W) + self.de = Entry(top, width=13, font=FDBFONT) self.de.grid(row=1, column=1, sticky=W, padx=3, pady=2) - self.de.insert(0, qdb.byid[s].date) - self.chodate = qdb.byid[s].date - self.be = Entry(top, width=5, font=fdbfont) + self.de.insert(0, QDB.byid[s].date) + self.chodate = QDB.byid[s].date + self.be = Entry(top, width=5, font=FDBFONT) self.be.grid(row=3, column=1, sticky=W, padx=3, pady=2) # self.be.configure(bg='gold') # test yes works - self.be.insert(0, qdb.byid[s].band) - self.choband = qdb.byid[s].band - self.ce = Entry(top, width=11, font=fdbfont) + self.be.insert(0, QDB.byid[s].band) + self.choband = QDB.byid[s].band + self.ce = Entry(top, width=11, font=FDBFONT) self.ce.grid(row=5, column=1, sticky=W, padx=3, pady=2) - self.ce.insert(0, qdb.byid[s].call) - self.chocall = qdb.byid[s].call - self.re = Entry(top, width=24, font=fdbfont) + self.ce.insert(0, QDB.byid[s].call) + self.chocall = QDB.byid[s].call + self.re = Entry(top, width=24, font=FDBFONT) self.re.grid(row=6, column=1, sticky=W, padx=3, pady=2) - self.re.insert(0, qdb.byid[s].rept) - self.chorept = qdb.byid[s].rept - self.pe = Entry(top, width=5, font=fdbfont) + self.re.insert(0, QDB.byid[s].rept) + self.chorept = QDB.byid[s].rept + self.pe = Entry(top, width=5, font=FDBFONT) self.pe.grid(row=7, column=1, sticky=W, padx=3, pady=2) - self.pe.insert(0, qdb.byid[s].powr) - self.chopowr = qdb.byid[s].powr - self.oe = Entry(top, width=3, font=fdbfont) + self.pe.insert(0, QDB.byid[s].powr) + self.chopowr = QDB.byid[s].powr + self.oe = Entry(top, width=3, font=FDBFONT) self.oe.grid(row=9, column=1, sticky=W, padx=3, pady=2) - self.oe.insert(0, qdb.byid[s].oper) - self.chooper = qdb.byid[s].oper - self.le = Entry(top, width=3, font=fdbfont) + self.oe.insert(0, QDB.byid[s].oper) + self.chooper = QDB.byid[s].oper + self.le = Entry(top, width=3, font=FDBFONT) self.le.grid(row=10, column=1, sticky=W, padx=3, pady=2) - self.le.insert(0, qdb.byid[s].logr) - self.chologr = qdb.byid[s].logr + self.le.insert(0, QDB.byid[s].logr) + self.chologr = QDB.byid[s].logr bf = Frame(top) bf.grid(row=11, columnspan=2, sticky=EW, pady=2) bf.grid_columnconfigure((0, 1, 2), weight=1) - db = Button(bf, text=' Delete ', font=fdbfont, command=self.dele) + db = Button(bf, text=' Delete ', font=FDBFONT, command=self.dele) db.grid(row=1, sticky=EW, padx=3) - sb = Button(bf, text=' Save ', font=fdbfont, command=self.submit) + sb = Button(bf, text=' Save ', font=FDBFONT, command=self.submit) sb.grid(row=1, column=1, sticky=EW, padx=3) - qb = Button(bf, text=' Dismiss ', font=fdbfont, command=self.quitb) + qb = Button(bf, text=' Dismiss ', font=FDBFONT, command=self.quitb) qb.grid(row=1, column=2, sticky=EW, padx=3) # self.wait_window(top) def submit(self): """submit edits""" - global editedornot + global EDITEDORNOT error = 0 changer = 0 # 0 = no change. 1= change except band and call. 2 = change in call or band t = self.de.get().strip() # date time @@ -3613,7 +3613,7 @@ def submit(self): #print "the Operator has changed." changer = 1 self.oe.configure(bg='white') - if participants.has_key(t): + if PARTICIPANTS.has_key(t): newopr = t #print newopr else: @@ -3624,7 +3624,7 @@ def submit(self): #print "the logger has changed." changer = 1 self.le.configure(bg='white') - if participants.has_key(t): + if PARTICIPANTS.has_key(t): newlogr = t #print newlogr else: @@ -3642,14 +3642,14 @@ def submit(self): # delete and enter new data because something other than band or call has changed. # print "no errors, enter data" reason = "edited" - qdb.delete(self.node, self.seq, reason) - qdb.postnew(newdate, newcall, newband, newrept, newopr, newlogr, newpowr) + QDB.delete(self.node, self.seq, reason) + QDB.postnew(newdate, newcall, newband, newrept, newopr, newlogr, newpowr) self.top.destroy() - txtbillb.insert(END, " EDIT Successful\n") + TXTBILLB.insert(END, " EDIT Successful\n") topper() if changer == 2: #band or call changed so check for dupe before submitting to log. - if qdb.dupck(newcall, newband): # dup check for new data + if QDB.dupck(newcall, newband): # dup check for new data print 'Edit is a DUPE. No action performed.' self.crazytxt.set("This is a DUPE") self.crazyclr.set('pink2') @@ -3659,17 +3659,17 @@ def submit(self): # delete and enter new data # print "no errors, enter data" reason = "edited" - qdb.delete(self.node, self.seq, reason) - qdb.postnew(newdate, newcall, newband, newrept, newopr, newlogr, newpowr) + QDB.delete(self.node, self.seq, reason) + QDB.postnew(newdate, newcall, newband, newrept, newopr, newlogr, newpowr) self.top.destroy() - editedornot = "1" - txtbillb.insert(END, " EDIT Successful\n") + EDITEDORNOT = "1" + TXTBILLB.insert(END, " EDIT Successful\n") topper() def dele(self): print "delete entry" reason = 'deleteclick' - qdb.delete(self.node, self.seq, reason) + QDB.delete(self.node, self.seq, reason) self.top.destroy() def quitb(self): @@ -3679,18 +3679,18 @@ def quitb(self): def edit_dialog(node, seq): 'edit log entry' - dummy = Edit_Dialog(root, node, seq) + dummy = Edit_Dialog(ROOT, node, seq) def log_select(e): 'process mouse left-click on log window' # print e.x,e.y - t = logw.index("@%d,%d" % (e.x, e.y)) + t = LOGW.index("@%d,%d" % (e.x, e.y)) # print t line, dummy = t.split('.') line = int(line) # print line - logtext = logw.get('%d.0' % line, '%d.82' % line) + logtext = LOGW.get('%d.0' % line, '%d.82' % line) # print logtext dummy = logtext[0:8].strip() seq = logtext[65:69].strip() @@ -3712,11 +3712,11 @@ def log_select(e): except ValueError: return 'break' print stn, seq, bxnd, cxll - if stn == node: # only edit my own Q's + if stn == NODE: # only edit my own Q's # Also check to make sure the call isn't previously deleted - if qdb.dupck(cxll, bxnd): + if QDB.dupck(cxll, bxnd): # Now we check to see if the entry is still in the log - bid, dummy, dummy = qdb.cleanlog() # get a clean log + bid, dummy, dummy = QDB.cleanlog() # get a clean log stnseq = stn +"|"+str(seq) if stnseq in bid: edit_dialog(stn, seq) @@ -3729,40 +3729,40 @@ def log_select(e): print "Cannot edit another person's contact." return 'break' -updatect = 0 +UPDATECT = 0 # This function updated from 152i def update(): "timed updater" - global updatect - root.after(1000, update) # reschedule early for reliability - sms.prout() # 1 hz items + global UPDATECT + ROOT.after(1000, update) # reschedule early for reliability + SMS.prout() # 1 hz items updatebb() - net.si.age_data() - mclock.adjust() + NET.si.age_data() + MCLOCK.adjust() # if mclock.level == 0: # time master broadcasts time more frequently # net.bcast_time() - updatect += 1 + UPDATECT += 1 # if (updatect % 5) == 0: # 5 sec # net.bcast_now() - if (updatect % 10) == 0: # 10 sec + if (UPDATECT % 10) == 0: # 10 sec updateqct() # this updates rcv packet fail renew_title() # this sends status broadcast - if (updatect % 30) == 0: # 30 sec - mclock.update() - if updatect > 59: # 60 sec - updatect = 0 -root.bind('', focevent) -txtbillb.bind('', kevent) -logw.bind('', kevent) # use del key for?xx -logw.bind('', log_select) # start of log edit -root.after(1000, update) # 1 hz activity -root.mainloop() # gui up + if (UPDATECT % 30) == 0: # 30 sec + MCLOCK.update() + if UPDATECT > 59: # 60 sec + UPDATECT = 0 +ROOT.bind('', focevent) +TXTBILLB.bind('', kevent) +LOGW.bind('', kevent) # use del key for?xx +LOGW.bind('', log_select) # start of log edit +ROOT.after(1000, update) # 1 hz activity +ROOT.mainloop() # gui up print "\nShutting down" # the end was updated from 152i -band = 'off' # gui down, xmt band off, preparing to quit -net.bcast_now() # push band out +BAND = 'off' # gui down, xmt band off, preparing to quit +NET.bcast_now() # push band out time.sleep(0.2) saveglob() # save globals print " globals saved" From 1388c4341401ad9720faac0a8e7d54265727a8da Mon Sep 17 00:00:00 2001 From: Larry Gadallah Date: Sun, 30 Jun 2019 21:21:08 -0700 Subject: [PATCH 2/3] Ran code through PyCharm's formatter, got rid of trailing whitespace --- FDLog.py | 325 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 173 insertions(+), 152 deletions(-) diff --git a/FDLog.py b/FDLog.py index 2cf288b..1793314 100755 --- a/FDLog.py +++ b/FDLog.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python import os import time import string @@ -10,19 +10,17 @@ import calendar import sqlite3 from Tkinter import Tk, END, NORMAL, DISABLED, re, sys, Toplevel, Frame, Label, Entry, Button, \ -W, EW, E, NONE, NSEW, NS, StringVar, Radiobutton, Tk, Menu, Menubutton, Text, Scrollbar, Checkbutton, RAISED, IntVar - + W, EW, E, NONE, NSEW, NS, StringVar, Radiobutton, Tk, Menu, Menubutton, Text, Scrollbar, Checkbutton, RAISED, IntVar # This needs to be tested on different networks and cross platform. -# +# # KD4SIR - Will probably work on copy/paste functionality -# KC7SDA - Will check network and platform compatibility and upper/lower case entry - +# KC7SDA - Will check network and platform compatibility and upper/lower case entry # Originally "WB6ZQZ's Field Day Logging Program" written in 1984. -# Alan Biocca (as WB6ZQZ) ported it to python with GNU in 2002. -# Our (SCICSG) code starts from: +# Alan Biocca (as WB6ZQZ) ported it to python with GNU in 2002. +# Our (SCICSG) code starts from: # FDLog 1-149-2 2011/07/11 # Copyright 2002-2013 by Alan Biocca (W6AKB) (www.fdlog.info) # FDLog is distributed under the GNU Public License @@ -33,7 +31,7 @@ # FDLog_Enhanced at Github.com # Copyright 2014-2019 South Central Indiana Communications Support Group # Copyright 2019 Curtis E. Mills (WE7U) -# +# # Our Goals are twofold: # 1: Improve on fdlog faster with open and directed collaboration. # This is now on github as FDLog_Enhanced. @@ -166,20 +164,21 @@ def adjust(self): MCLOCK = clock_class() + def initialize(): - k = "" # keyboard input - z = "" # answer counter - kfd = 0 # FD indicator to skip questions + k = "" # keyboard input + z = "" # answer counter + kfd = 0 # FD indicator to skip questions print "\n \n" print "For the person in Charge of Logging:" print "*** ONLY ONE PERSON CAN DO THIS ***" - print "Do you need to set up the event? Y or N" + print "Do you need to set up the event? Y or N" print " if in doubt select N" while z != "1": k = string.lower(string.strip(sys.stdin.readline())[:1]) if k == "y": z = "1" if k == "n": z = '1' - if z != "1": print "Press Y or N please" + if z != "1": print "Press Y or N please" if k == "y": # Field Day or VHF contest z = "" @@ -192,13 +191,13 @@ def initialize(): if k == "v": z = '1' if z != "1": print "Press F, W or V please" if k == "f": - kfd = 1 #used later to skip grid square question.SAH + kfd = 1 # used later to skip grid square question.SAH GLOBDB.put('contst', "FD") QDB.globalshare('contst', "FD") # global to db renew_title() print "Have a nice Field Day!" if k == "w": - kfd = 2 #used later to skip grid square question + kfd = 2 # used later to skip grid square question GLOBDB.put('contst', "WFD") QDB.globalshare('contst', "WFD") # global to db renew_title() @@ -269,14 +268,14 @@ def initialize(): while k == "": print "Please type the grid square. (For FD type none)" k = string.strip(sys.stdin.readline()) - k = k.upper() # changed the init so the grid square will be cap + k = k.upper() # changed the init so the grid square will be cap else: GLOBDB.put('grid', k) QDB.globalshare('grid', k) # global to db renew_title() print k, "will be the grid." - if kfd !=2: - #questions for vhf and fd, skip for wfd + if kfd != 2: + # questions for vhf and fd, skip for wfd # Public Place z = "" print "Will the location be in a public place?" @@ -285,7 +284,7 @@ def initialize(): k = string.lower(string.strip(sys.stdin.readline())[:1]) if k == "y": z = "1" if k == "n": z = '1' - if z == "" : print "Press Y or N please" + if z == "": print "Press Y or N please" if k == "y": GLOBDB.put('public', "A public location") QDB.globalshare('public', "A public location") # global to db @@ -304,7 +303,7 @@ def initialize(): k = string.lower(string.strip(sys.stdin.readline())[:1]) if k == "y": z = "1" if k == "n": z = '1' - if z == "" : print "Press Y or N please" + if z == "": print "Press Y or N please" if k == "y": GLOBDB.put('infob', "1") QDB.globalshare('infob', "1") # global to db @@ -315,7 +314,7 @@ def initialize(): QDB.globalshare('infob', "0") # global to db renew_title() print "An information table is easy points" - #Time Master - oh yeah the big question + # Time Master - oh yeah the big question z = "" print "\n It is recommended that the first computer" print "set up should also be the time master." @@ -326,14 +325,14 @@ def initialize(): k = string.lower(string.strip(sys.stdin.readline())[:1]) if k == "y": z = "1" if k == "n": z = '1' - if z == "" : print "Press Y or N please" + if z == "": print "Press Y or N please" if k == "y": GLOBDB.put('tmast', NODE) QDB.globalshare('tmast', NODE) # global to db renew_title() print "Time travels to you!" if k == "n": - pass + pass return @@ -400,7 +399,7 @@ def log(self, n): # add item to journal logfile table (and other tables...) # update sequence counts for journals? sqdb.commit() # do the commit if n.band == '*QST': - print("QST\a " + n.rept+" -"+n.logr) # The "\a" emits the beep sound for QST + print("QST\a " + n.rept + " -" + n.logr) # The "\a" emits the beep sound for QST class qsodb: @@ -435,11 +434,11 @@ def ldrec(self, line): # load log entry fm text def loadfile(self): print "Loading Log File" i, s, log = 0, 0, [] - global SQDB # setup sqlite database connection + global SQDB # setup sqlite database connection SQDB = SQDB() log = SQDB.readlog() # read the database for ln in log: - if ln[0] == 'q': # qso db line + if ln[0] == 'q': # qso db line r = QDB.new(0) try: r.ldrec(ln) @@ -516,7 +515,6 @@ def prlogln(self, s): (s.date[4:11], s.band, s.call[:11], s.rept[:24], s.powr, s.oper, s.logr, s.seq, s.src) return ln - def prlog(self): "print log in time order" l = self.filterlog("") @@ -575,61 +573,63 @@ def vhf_cabrillo(self): i.date, freq, mod, date, tim, mycall, mygrid, call, grid)) l.sort() # sort data with prepended date.time for i in l: print i[13:] # rm sort key date.time -# added support for winter field day, this outputs the cabrillo format that is posted on their website. + + # added support for winter field day, this outputs the cabrillo format that is posted on their website. def winter_fd(self): "output Winter Field day QSO data in cabrillo format:" - #vars: - band_map = {'160': '1800', '80': '3500', '40': '7000', '20': '14000','15': '21000','10': '28000','6': '50', '2': '144', '220': '222', '440': '432', '900': '902', '1200': '1.2G'} + # vars: + band_map = {'160': '1800', '80': '3500', '40': '7000', '20': '14000', '15': '21000', '10': '28000', '6': '50', + '2': '144', '220': '222', '440': '432', '900': '902', '1200': '1.2G'} dummy, n, dummy = self.cleanlog() l = [] mycall = string.upper(GD.getv('fdcall')) mycat = GD.getv('class') mystate, mysect = GD.getv('sect').split("-") - #number of tx + # number of tx txnum = mycat[:-1] - #data crunching: - - #QSO log generation: + # data crunching: + + # QSO log generation: for i in n.values(): freq = "%s" % i.band[:-1] # band - #if freq in band_map: freq = band_map[freq] + # if freq in band_map: freq = band_map[freq] mod = i.band[-1:] # mode if mod == "c": mod = "CW" if mod == "p": mod = "PH" - if mod == "d": mod = "DI" # per 2019 rules + if mod == "d": mod = "DI" # per 2019 rules date = "20%2s-%2s-%2s" % (i.date[0:2], i.date[2:4], i.date[4:6]) - #date = "%2s-%2s-20%2s" % (i.date[2:4], i.date[4:6], i.date[0:2]) + # date = "%2s-%2s-20%2s" % (i.date[2:4], i.date[4:6], i.date[0:2]) tim = i.date[7:11] call = i.call cat, sect = i.rept.split(" ") if '/' in call: # split off grid from call call, grid = call.split('/') - #cabrillo example: QSO: 40 DI 2019-01-19 1641 KC7SDA 1H WWA KZ9ZZZ 1H NFL + # cabrillo example: QSO: 40 DI 2019-01-19 1641 KC7SDA 1H WWA KZ9ZZZ 1H NFL l.append("%sQSO: %-5s %-2s %-10s %4s %-10s %-2s %-5s %-10s %-2s %-5s" % ( - i.date,freq, mod, date, tim, mycall, mycat, mysect, call, cat, sect)) + i.date, freq, mod, date, tim, mycall, mycat, mysect, call, cat, sect)) l.sort() # sort data with prepended date.time - - #check operator (single or multi op): + + # check operator (single or multi op): cat_op = "" if len(PARTICIPANTS) > 1: cat_op = "MULTI-OP" else: cat_op = "SINGLE-OP" - - #check fixed or portable? - - #tx power: - - #calls for ops: + + # check fixed or portable? + + # tx power: + + # calls for ops: ops_calls_list = [] - #print(participants) - #participants: {u'am': u'am, art miller, kc7sda, 37, '} + # print(participants) + # participants: {u'am': u'am, art miller, kc7sda, 37, '} for i in PARTICIPANTS.values(): dummy, dummy, cs, dummy, dummy = i.split(", ") ops_calls_list.append(string.upper(cs)) ops_calls = ', '.join(ops_calls_list) - - #output + + # output print "Winter field day Cabrillo output" print "START-OF-LOG: 3.0" print "Created-By: FDLog (https://github.com/scotthibbs/FDLog_Enhanced)" @@ -638,24 +638,24 @@ def winter_fd(self): print "LOCATION: " + mystate print "ARRL-SECTION: " + mysect print "CATEGORY-OPERATOR: " + cat_op - print "CATEGORY-STATION: " #fixed or portable - print "CATEGORY_TRANSMITTER: " + txnum # how many transmitters - print "CATEGORY_POWER: LOW" #qrp low or high - print "CATEGORY_ASSISTED: NON-ASSISTED" #assisted or non-assisted - print "CATEGORY-BAND: ALL" # leave for wfd - print "CATEGORY-MODE: MIXED" #leave for wfd - print "CATEGORY-OVERLAY: OVER-50" # leave for wfd - print "SOAPBOX: " #fill in? - print "CLAIMED-SCORE: " #figure out score and add - print "OPERATORS: " + ops_calls #agregate the ops + print "CATEGORY-STATION: " # fixed or portable + print "CATEGORY_TRANSMITTER: " + txnum # how many transmitters + print "CATEGORY_POWER: LOW" # qrp low or high + print "CATEGORY_ASSISTED: NON-ASSISTED" # assisted or non-assisted + print "CATEGORY-BAND: ALL" # leave for wfd + print "CATEGORY-MODE: MIXED" # leave for wfd + print "CATEGORY-OVERLAY: OVER-50" # leave for wfd + print "SOAPBOX: " # fill in? + print "CLAIMED-SCORE: " # figure out score and add + print "OPERATORS: " + ops_calls # agregate the ops print "NAME: " + GD.getv('fmname') print "ADDRESS: " + GD.getv('fmad1') print "ADDRESS-CITY: " + GD.getv('fmcity') print "ADDRESS-STATE: " + GD.getv('fmst') - print "ADDRES-POSTALCODE: " + GD.getv('fmzip') #zip - print "ADDRESS-COUNTRY: USA" # hard coded for now, possibly change later - print "EMAIL: " + GD.getv('fmem') #email address - #print log: + print "ADDRES-POSTALCODE: " + GD.getv('fmzip') # zip + print "ADDRESS-COUNTRY: USA" # hard coded for now, possibly change later + print "EMAIL: " + GD.getv('fmem') # email address + # print log: for i in l: print i[13:] # rm sort key date.time print "END-OF-LOG:" @@ -735,7 +735,7 @@ def delete(self, nod, seq, reason): LOGW.configure(state=NORMAL) LOGW.delete(0.1, END) LOGW.insert(END, "\n") - # Redraw the logw text window (on delete) to only show valid calls in the log. + # Redraw the logw text window (on delete) to only show valid calls in the log. # This avoids confusion by only listing items in the log to edit in the future. l = [] for i in sorted(a.values()): @@ -1004,12 +1004,12 @@ def partck(self, wcall): # to debug: print ("%s dcall matches %s xcall" % (dcall, xcall)) if GD.getv('contst').upper() == "VHF": return xcall # vhf contest - return call # field day + return call # field day if dcall == call: - #to debug: print ("%s dcall matches %s call" % (dcall, call)) + # to debug: print ("%s dcall matches %s call" % (dcall, call)) if GD.getv('contst').upper() == "VHF": - return xcall # vhf contest - return call # field day + return xcall # vhf contest + return call # field day def logdup(self): """enter into dup log""" @@ -1102,6 +1102,7 @@ def wasrpt(self): r.append(i) return r + class node_info: """Threads and networking section""" nodes = {} @@ -1247,21 +1248,21 @@ def nod_on_bands(self): class netsync: """network database synchronization""" - # removed netmask - it isn't used anywhere in the program from what I can tell (do a search for 'netmask' this is the only place you find it) - # re-coded the ip address calculation to smooth it out and make it cross platform compatible - #netmask = '255.255.255.0' + # removed netmask - it isn't used anywhere in the program from what I can tell (do a search for 'netmask' this is the only place you find it) + # re-coded the ip address calculation to smooth it out and make it cross platform compatible + # netmask = '255.255.255.0' rem_adr = "" # remote bc address authkey = hashlib.md5() pkts_rcvd, fills, badauth_rcvd, send_errs = 0, 0, 0, 0 hostname = socket.gethostname() s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) try: - s.connect(("8.8.8.8", 53)) - my_addr = s.getsockname()[0] + s.connect(("8.8.8.8", 53)) + my_addr = s.getsockname()[0] except: - my_addr = '127.0.0.1' + my_addr = '127.0.0.1' finally: - s.close() + s.close() print "\n IP address is: %s\n" % my_addr bc_addr = re.sub(r'[0-9]+$', '255', my_addr) # calc bcast addr si = node_info() # node info @@ -1442,7 +1443,7 @@ def setv(self, name, value, timestamp): if len(value) > i.maxl: # too long return "error - value too long: %s = %s" % (name, value) if name == 'grid': - value = value.upper() # added to properly format grid (ie CN88 not cn88) + value = value.upper() # added to properly format grid (ie CN88 not cn88) if not re.match(i.okg, value): # bad grammar return "set error - invalid value: %s = %s" % (name, value) if timestamp > i.ts: # timestamp later? @@ -1469,6 +1470,7 @@ def sethelp(self): l.sort() viewtextl(l) + # modifed the sect setting regex to accept both lower and upper case # added additional form fields (also fixed 'from' to 'form') for wfd NOTE: set commands have a max length of 6! GD = global_data() @@ -1517,19 +1519,19 @@ def prmsg(self, msg): def prout(self): """get message from queue for printing""" - # Check to see if the log window has been deleted + # Check to see if the log window has been deleted self.lock.acquire() while self.msgs: LOGW.configure(state=NORMAL) LOGW.see(END) - nod = self.msgs[0][70:81] # color local entries + nod = self.msgs[0][70:81] # color local entries seq = self.msgs[0][65:69].strip() seq = int(seq) stn = self.msgs[0][69:].strip() if nod == NODE: # Added a check to see if in the log to print blue or not bid, dummy, dummy = QDB.cleanlog() # get a clean log - stnseq = stn +"|"+str(seq) + stnseq = stn + "|" + str(seq) if stnseq in bid: LOGW.insert(END, "%s\n" % self.msgs[0], "b") else: @@ -1549,6 +1551,7 @@ def now(): t = time.strftime("%y%m%d.%H%M%S", n) # compact version YY return t + def tmtofl(a): """time to float in seconds, allow milliseconds""" # Reworked in 152i @@ -1557,6 +1560,7 @@ def tmtofl(a): return calendar.timegm((2000 + int(a[0:2]), int(a[2:4]), int(a[4:6]), int(a[7:9]), int(a[9:11]), float(a[11:]), 0, 0, 0)) + def tmsub(a, b): """time subtract in seconds""" return tmtofl(a) - tmtofl(b) @@ -1564,6 +1568,7 @@ def tmsub(a, b): class GlobalDb: """new sqlite globals database fdlog.sq3 replacing globals file""" + def __init__(self): self.dbPath = GLOBF[0:-4] + '.sq3' print " Using local value database", self.dbPath @@ -2046,6 +2051,7 @@ def contestlog(pr): print print "entry and log written to file", LOGFILE + # setup for phonetics printout ## to get phonetics on bottom of gui? # d = {"a":"alpha ","b":"bravo ","c":"charlie ","d":"delta ","e":"echo ", \ # "f":"foxtrot ","g":"golf ","h":"hotel ","i":"india ","j":"juliett ", \ @@ -2086,6 +2092,7 @@ def bandset(b): BANDB[b].select() renew_title() + def bandoff(): """ To set the band to off""" bandset('off') @@ -2125,8 +2132,8 @@ def dialog(self): fr2.grid(row=1, column=0, sticky=EW, pady=3) fr2.grid_columnconfigure((0, 1), weight=1) Label(fr2, text='=Save', font=FDBFONT, foreground='red').grid(row=3, column=0, sticky=W) - #Button(fr2, text='Save', font=fdbfont, command=s.applybtn) .grid(row=3, column=1, sticky=EW, padx=3) - Button(fr2, text='Dismiss', font=FDBFONT, command=s.quitbtn) .grid(row=3, column=2, sticky=EW, padx=3) + # Button(fr2, text='Save', font=fdbfont, command=s.applybtn) .grid(row=3, column=1, sticky=EW, padx=3) + Button(fr2, text='Dismiss', font=FDBFONT, command=s.quitbtn).grid(row=3, column=2, sticky=EW, padx=3) # Bound enter key to save entries s.t.bind('', lambda event: s.applybtn) @@ -2155,8 +2162,8 @@ def lookup(self): else: self.vist.insert(END, vist) return 1 - - @property #This added so I can use the binding + + @property # This added so I can use the binding def applybtn(self): global PARTICIPANTS # print "store" @@ -2248,6 +2255,7 @@ def renew_title(): (call, clas, sec, NODE, h, m, t[-6:-4], t[-4:-2], t[2:4], t[4:6], PORT_BASE)) NET.bcast_now() # this is periodic bcast... + def setnode(new): global NODE bandoff() @@ -2257,6 +2265,7 @@ def setnode(new): LBLNODE.configure(text="My Node: %s" % NODE, font=FDFONT, foreground='royalblue', background='lightgrey') # Had to add the above so that the new lblnode could be updated + def applyprop(e=''): """apply property""" global OPERATOR, LOGGER, POWER, NODE @@ -2276,6 +2285,7 @@ def applyprop(e=''): else: print 'bad syntax', new + def pdiag(label, value, valid_re, wid): "property dialog box" CF['p'] = Toplevel(ROOT) @@ -2297,9 +2307,10 @@ def pdiag(label, value, valid_re, wid): CF['p'].bind('', lambda e: (CF['p'].destroy())) CF['e'].focus() + def noddiag(): pdiag('Node', NODE, r'[A-Za-z0-9-]{1,8}$', 8) - #def authdiag(): + # def authdiag(): # pdiag('AuthKey',authk,r'.{3,12}$',12) @@ -2360,6 +2371,7 @@ def viewlogfs(nod): lg = QDB.filterlogst(nod) viewtextl(lg, "Log Filtered for %s" % nod) + def viewwasrpt(): r = QDB.wasrpt() viewtextl(r, "Worked All States Report") @@ -2373,7 +2385,6 @@ def updatebb(): r, cl, vh, go = NET.si.nod_on_bands() anytext = "VHF " - def whosonfirst(event): # Cleaned up whos on band (with section of .ba report) d = {} @@ -2386,12 +2397,11 @@ def whosonfirst(event): topper() TXTBILLB.see(END) - - def whosonsecond(event): global WOF WOF = "" - #tkMessageBox.destroy + + # tkMessageBox.destroy for i in BANDS: dummy = 0 @@ -2413,7 +2423,8 @@ def whosonsecond(event): BANDB[bm].bind("", whosonfirst) BANDB[bm].bind("", whosonsecond) else: - bc = 'darkorange'; sc = 'red' + bc = 'darkorange'; + sc = 'red' BANDB[bm].bind("", whosonfirst) BANDB[bm].bind("", whosonsecond) BANDB[bm].configure(background=bc, selectcolor=sc) @@ -2431,7 +2442,7 @@ def whosonsecond(event): else: vhfree = 0 ts = cl - #ts = cl + max(0, vh-vhfree) # total sta = class + excess vhf stations + # ts = cl + max(0, vh-vhfree) # total sta = class + excess vhf stations # Fixed VHF to reflect a free transmitter and warn if two vhf rigs are used clc = 'gold' if ts == cltg: @@ -2461,6 +2472,7 @@ def whosonsecond(event): if go > gotatg: goc = 'pink2' BANDB['GOTA'].configure(text='GOTA %s/%s' % (go, gotatg), background=goc) + def updateqct(): "update contact count" dummy, dummy, qpop, qplg, dummy, dummy, dummy, dummy, cwq, digq, fonq, dummy, gotaq, dummy, dummy = \ @@ -2509,7 +2521,8 @@ def updateqct(): else: t = "Alone? Not receiving data from others. Firewall?" if NET.send_errs: - t = "SEND FAIL - Not sending data to others. Firewall?"; NET.send_errs = 0 + t = "SEND FAIL - Not sending data to others. Firewall?"; + NET.send_errs = 0 if AUTHK == '': t = "NO AUTHKEY SELECTED" if NODE == '': @@ -2519,6 +2532,7 @@ def updateqct(): else: LBLNET.configure(text="Network OK", background='lightgrey') + def BandButtons(w): "create band buttons" global SV @@ -2545,8 +2559,8 @@ def BandButtons(w): b += 1 a += 1 for i, j, dummy in (('Class', 0, 5), - ('VHF', 1, 13), - ('GOTA', 2, 9)): + ('VHF', 1, 13), + ('GOTA', 2, 9)): BANDB[i] = Button(w, text=i, font=FDFONT) BANDB[i].grid(row=j, column=a, sticky=NSEW) w.grid_columnconfigure(a, weight=1) @@ -2604,7 +2618,7 @@ def testqgen(n): LOGFILE = "fdlog.log" # printable log file (contest entry) GLOBF = "fdlog.dat" # persistent global file KBUF = "" # keyboard line buffer -GOBACK = "" # needed to print the last line entered with up arrow +GOBACK = "" # needed to print the last line entered with up arrow loadglob() # load persistent globals from file print if NODE == "": @@ -2616,7 +2630,7 @@ def testqgen(n): print " (7 characters}" k = string.lower(string.strip(sys.stdin.readline())[:8]) if len(k) == 8: - print "That's too many.. (Marc? is that you?)" # Thanks to Marc Fountain K9MAF for the correction. + print "That's too many.. (Marc? is that you?)" # Thanks to Marc Fountain K9MAF for the correction. k = k[:7] Z = len(k) if k != 'gota': @@ -2624,7 +2638,7 @@ def testqgen(n): if k == 'gota': print "please restart the program." sys.exit() - else: + else: if Z < 4: print "um yeah.. 7 characters.... (restart if your gota)" k = string.lower(string.strip(sys.stdin.readline())[:8]) @@ -2637,7 +2651,7 @@ def testqgen(n): Z = len(k) ## 1. if there is more than four characters ## 2. add the rest with randoms - + else: print "Thank You!!" NODE = k + random.choice('abcdefghijklmnopqrstuvwxyz') @@ -2722,16 +2736,15 @@ def testqgen(n): RESOURCEMENU.add_command(label="ARRL Band Chart (pdf)", command=lambda: os.startfile('Bands.pdf')) RESOURCEMENU.add_command(label="ARRL Band Plan", command=lambda: viewtextf('ARRL_Band_Plans.txt', "ARRL Band Plan")) # This is not needed with the band chart giving the same info -#resourcemenu.add_command(label="FD Frequency List", command=lambda: viewtextf('frequencies.txt', "FD Frequency List")) +# resourcemenu.add_command(label="FD Frequency List", command=lambda: viewtextf('frequencies.txt', "FD Frequency List")) # Removed the propagation report. We don't use it -#resourcemenu.add_command(label="Propagation Info", command=lambda: viewtextf('propagation.txt', "Propagation Info")) +# resourcemenu.add_command(label="Propagation Info", command=lambda: viewtextf('propagation.txt', "Propagation Info")) # Created a W1AW menu W1AWMENU = Menu(MENU, tearoff=0) MENU.add_cascade(label="W1AW", menu=W1AWMENU) W1AWMENU.add_command(label="W1AW Schedule", command=lambda: viewtextf('w1aw.txt', 'W1AW Schedule')) W1AWMENU.add_command(label="NTS Message", command=lambda: os.startfile('NTS_eg.txt')) - # Time Conversion Chart TZCHART = """ @@ -2776,6 +2789,7 @@ def testcmd(name, rex, value): KBUF = "" return value, default != value + def setoper(op): "set operator" global OPERATOR @@ -2808,9 +2822,9 @@ def setlog(logr): PCOLOR = 'pink2' # Add "who" button to display messagebox with operators on band when clicked. # Determined that this is not needed now that the mouse over report is cleaner. -#opwho = Menubutton(f1b, text='WHO ', font=fdfont, relief='raised', +# opwho = Menubutton(f1b, text='WHO ', font=fdfont, relief='raised', # background='lightgrey', foreground='royalblue') -#opwho.grid(row=0, column=0, sticky=NSEW) +# opwho.grid(row=0, column=0, sticky=NSEW) # Operator OPMB = Menubutton(F1B, text='Operator', font=FDFONT, relief='raised', background=OCOLOR) @@ -2836,6 +2850,7 @@ def setlog(logr): LOGDS.config(menu=LOGDSU, direction='below') LOGDSU.add_command(label="Add New Logger", command=NEWPART.dialog) + def buildmenus(): OPDSU.delete(0, END) LOGDSU.delete(0, END) @@ -2845,7 +2860,7 @@ def buildmenus(): # had to take out the $ which looks for the end of value # Decided non-hams can be in operator field but will check for license before logging # m = re.match(r'[a-z0-9]+, [a-zA-Z ]+, ([a-z0-9]+)',i) - #if m: opdsu.add_command(label=i, command=lambda n=i: (setoper(n))) + # if m: opdsu.add_command(label=i, command=lambda n=i: (setoper(n))) OPDSU.add_command(label=i, command=lambda n=i: (setoper(n))) LOGDSU.add_command(label=i, command=lambda n=i: (setlog(n))) OPDSU.add_command(label="Add New Operator", command=NEWPART.dialog) @@ -2930,7 +2945,7 @@ def setpwr(p): POWCB.config(background=pcolor) POWLBL.config(background=pcolor) - + PWRMB = Menubutton(F1B, text="Power", font=FDFONT, relief='raised', background=PCOLOR) PWRMB.grid(row=0, column=6, sticky=NSEW) @@ -3076,26 +3091,29 @@ def showthiscall(call): def mhelp(): viewtextf('Keyhelp.txt') + SECNAME = {} + def readSections(): """this will read the Arrl_sect.dat file for sections""" # This modified from Alan Biocca version 153d try: - fd = file("Arrl_sect.dat","r") # read section data + fd = file("Arrl_sect.dat", "r") # read section data while 1: - ln = fd.readline().strip() # read a line and put in db + ln = fd.readline().strip() # read a line and put in db if not ln: break if ln[0] == '#': continue try: - sec, dummy, dummy, dummy = string.split(ln,None,3) + sec, dummy, dummy, dummy = string.split(ln, None, 3) SECNAME[sec] = sec - except ValueError,e: - print "rd arrl sec dat err, itm skpd: ",e + except ValueError, e: + print "rd arrl sec dat err, itm skpd: ", e fd.close() - except IOError,e: + except IOError, e: print "read error during readSections", e + readSections() @@ -3196,7 +3214,7 @@ def proc_key(ch): KBUF = "" TXTBILLB.insert(END, "To edit: click on the log entry\n") return - #Found that .node needed fixing. Reworked + # Found that .node needed fixing. Reworked if re.match(r'[.]node', KBUF): if BAND != 'off': TXTBILLB.insert(END, "\nSet band off before changing node id\n") @@ -3209,7 +3227,7 @@ def proc_key(ch): setnode(NODE) KBUF = "" TXTBILLB.insert(END, "\n") - topper() + topper() return if re.match(r'[.]st$', KBUF): # status xx mv to gui print @@ -3256,7 +3274,7 @@ def proc_key(ch): # check for valid contact if (ch == '\r'): stat, ftm, dummy, sfx, call, xcall, rept = QDB.qparse(KBUF) - GOBACK = "%s %s" % (call, rept)# for the up arrow enhancement + GOBACK = "%s %s" % (call, rept) # for the up arrow enhancement if stat == 5: # whole qso parsed KBUF = "" if len(NODE) < 3: @@ -3265,7 +3283,7 @@ def proc_key(ch): elif QDB.dupck(xcall, BAND): # dup check TXTBILLB.insert(END, "\n\n ***DUPE*** on band %s ***DUPE***\n" % BAND) topper() - elif QDB.partck(xcall): # Participant check + elif QDB.partck(xcall): # Participant check TXTBILLB.insert(END, "\n Participant - not allowed \n") topper() elif xcall == string.lower(GD.getv('fdcall')): @@ -3282,10 +3300,10 @@ def proc_key(ch): # Checking Operator or Logger has a license legal = 0 if re.match(r'[a-z :]+ [a-zA-Z ]+, ([a-z0-9]+)', OPERATOR): - #print "%s has a license" % operator + # print "%s has a license" % operator legal = legal + 1 if re.match(r'[a-z :]+ [a-zA-Z ]+, ([a-z0-9]+)', LOGGER): - #print "%s has a license" % logger + # print "%s has a license" % logger legal = legal + 1 if legal == 0: TXTBILLB.insert(END, "\n\n The Operator or the logger needs a license.\n") @@ -3325,15 +3343,15 @@ def proc_key(ch): # vhf or other contest # allow everything m = "something" - if m == None: # match failed, do not allow and abort logging + if m == None: # match failed, do not allow and abort logging TXTBILLB.insert(END, " - ERROR: Bad exchange ( %s ) Please Try Again\n" % rept) topper() return # Check for valid section in report aaaaa = len(rept1) - #print "aaaaa is %s" % aaaaa + # print "aaaaa is %s" % aaaaa rept2 = rept1[3:aaaaa].strip() - #print "rept2 is %s" % rept2 + # print "rept2 is %s" % rept2 if rept2 in SECNAME: pass else: @@ -3353,7 +3371,7 @@ def proc_key(ch): kk += "\n " nx = 0 print kk - #print('\n'.join("{} : {}".format(k, v) for k, v in secName.items())) + # print('\n'.join("{} : {}".format(k, v) for k, v in secName.items())) TXTBILLB.insert(END, kk) TXTBILLB.insert(END, "\n Please try one of the sections above.") topper() @@ -3369,7 +3387,7 @@ def proc_key(ch): elif stat == 4: KBUF = "" # Added participant check here too - if QDB.partck(xcall): # Participant check + if QDB.partck(xcall): # Participant check TXTBILLB.insert(END, "\n Participant - not allowed \n") topper() elif showthiscall(call) == 0: @@ -3389,9 +3407,9 @@ def proc_key(ch): if ch == '\u1p': # up arrow reprints the input line if GOBACK != "": if KBUF == "": - TXTBILLB.insert(END, GOBACK) #print goBack info + TXTBILLB.insert(END, GOBACK) # print goBack info KBUF = GOBACK - else: + else: return else: KBUF = "" @@ -3416,7 +3434,7 @@ def proc_key(ch): showthiscall(call) KBUF = "" topper() - elif QDB.partck(xcall): # Participant check + elif QDB.partck(xcall): # Participant check TXTBILLB.insert(END, "\n Participant - not allowed \n") showthiscall(call) KBUF = "" @@ -3547,40 +3565,40 @@ def submit(self): """submit edits""" global EDITEDORNOT error = 0 - changer = 0 # 0 = no change. 1= change except band and call. 2 = change in call or band + changer = 0 # 0 = no change. 1= change except band and call. 2 = change in call or band t = self.de.get().strip() # date time if self.chodate != t: - #print "The date has changed." + # print "The date has changed." changer = 1 self.de.configure(bg='white') m = re.match(r'[0-9]{6}\.[0-9]{4,6}$', t) if m: newdate = t + '00'[:13 - len(t)] - #print newdate + # print newdate else: self.de.configure(bg='gold') error += 1 t = self.be.get().strip() # band mode if self.choband != t: - #print "the band has changed" + # print "the band has changed" changer = 2 self.be.configure(bg='white') m = re.match(r'(160|80|40|20|15|10|6|2|220|440|900|1200|sat)[cdp]$', t) if m: newband = t - #print newband + # print newband else: self.be.configure(bg='gold') error += 1 t = self.ce.get().strip() # call if self.chocall != t: - #print "the call has changed" + # print "the call has changed" changer = 2 self.ce.configure(bg='white') m = re.match(r'[a-z0-9/]{3,11}$', t) if m: newcall = t - #print newcall + # print newcall else: self.ce.configure(bg='gold') error += 1 @@ -3592,41 +3610,41 @@ def submit(self): m = re.match(r'.{4,24}$', t) if m: newrept = t - #print newrept + # print newrept else: self.re.configure(bg='gold') error += 1 t = self.pe.get().strip().lower() # power if self.chopowr != t: - #print "the power has changed." + # print "the power has changed." changer = 1 self.pe.configure(bg='white') m = re.match(r'[0-9]{1,4}n?$', t) if m: newpowr = t - #print newpowr + # print newpowr else: self.pe.configure(bg='gold') error += 1 t = self.oe.get().strip().lower() # operator if self.chooper != t: - #print "the Operator has changed." + # print "the Operator has changed." changer = 1 self.oe.configure(bg='white') if PARTICIPANTS.has_key(t): newopr = t - #print newopr + # print newopr else: self.oe.configure(bg='gold') error += 1 t = self.le.get().strip().lower() # logger if self.chologr != t: - #print "the logger has changed." + # print "the logger has changed." changer = 1 self.le.configure(bg='white') if PARTICIPANTS.has_key(t): newlogr = t - #print newlogr + # print newlogr else: self.le.configure(bg='gold') error += 1 @@ -3639,7 +3657,7 @@ def submit(self): self.crazylbl.configure(bg=self.crazyclr.get(), text=self.crazytxt.get()) error += 1 if changer == 1: - # delete and enter new data because something other than band or call has changed. + # delete and enter new data because something other than band or call has changed. # print "no errors, enter data" reason = "edited" QDB.delete(self.node, self.seq, reason) @@ -3648,7 +3666,7 @@ def submit(self): TXTBILLB.insert(END, " EDIT Successful\n") topper() if changer == 2: - #band or call changed so check for dupe before submitting to log. + # band or call changed so check for dupe before submitting to log. if QDB.dupck(newcall, newband): # dup check for new data print 'Edit is a DUPE. No action performed.' self.crazytxt.set("This is a DUPE") @@ -3681,7 +3699,7 @@ def edit_dialog(node, seq): 'edit log entry' dummy = Edit_Dialog(ROOT, node, seq) - + def log_select(e): 'process mouse left-click on log window' # print e.x,e.y @@ -3717,7 +3735,7 @@ def log_select(e): if QDB.dupck(cxll, bxnd): # Now we check to see if the entry is still in the log bid, dummy, dummy = QDB.cleanlog() # get a clean log - stnseq = stn +"|"+str(seq) + stnseq = stn + "|" + str(seq) if stnseq in bid: edit_dialog(stn, seq) else: @@ -3729,6 +3747,7 @@ def log_select(e): print "Cannot edit another person's contact." return 'break' + UPDATECT = 0 @@ -3753,6 +3772,8 @@ def update(): MCLOCK.update() if UPDATECT > 59: # 60 sec UPDATECT = 0 + + ROOT.bind('', focevent) TXTBILLB.bind('', kevent) LOGW.bind('', kevent) # use del key for?xx @@ -3773,17 +3794,17 @@ def update(): # Suggestions/To Do: # -# Grab out of order entry from Alan Biocca's FDLog. +# Grab out of order entry from Alan Biocca's FDLog. # # Change Participant entry so the name is on top. (It's odd to ask their initials first.) # # Would love another file to use for the "InfoNode" computer - # It will allow visitors/participants to log in - # It will show top 5 operators and top 5 loggers - # It will show worked all states - # Provide info on Amateur Radio (video and/or short articles to print?) - # Provide info on the local club - # fool-proof - no logging from this node. +# It will allow visitors/participants to log in +# It will show top 5 operators and top 5 loggers +# It will show worked all states +# Provide info on Amateur Radio (video and/or short articles to print?) +# Provide info on the local club +# fool-proof - no logging from this node. # # add node list display after db read during startup? # From 670cc46690c983b5936213c48723617d37d56459 Mon Sep 17 00:00:00 2001 From: Larry Gadallah Date: Sun, 30 Jun 2019 21:50:47 -0700 Subject: [PATCH 3/3] Getting rid of PyLint line-too-long warnings --- FDLog.py | 180 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 117 insertions(+), 63 deletions(-) diff --git a/FDLog.py b/FDLog.py index 1793314..3c4f52a 100755 --- a/FDLog.py +++ b/FDLog.py @@ -10,7 +10,8 @@ import calendar import sqlite3 from Tkinter import Tk, END, NORMAL, DISABLED, re, sys, Toplevel, Frame, Label, Entry, Button, \ - W, EW, E, NONE, NSEW, NS, StringVar, Radiobutton, Tk, Menu, Menubutton, Text, Scrollbar, Checkbutton, RAISED, IntVar + W, EW, E, NONE, NSEW, NS, StringVar, Radiobutton, Tk, Menu, Menubutton, Text, Scrollbar, \ + Checkbutton, RAISED, IntVar # This needs to be tested on different networks and cross platform. # @@ -372,8 +373,8 @@ def readlog(self): # ,srcId,srcIdx): # returns list of log journal i nl = [] for r in result: # print dir(r) - nl.append("|".join(('q', r['src'], str(r['seq']), r['date'], r['band'], r['call'], r['rept'], r['powr'], - r['oper'], r['logr'], ''))) + nl.append("|".join(('q', r['src'], str(r['seq']), r['date'], r['band'], r['call'], + r['rept'], r['powr'], r['oper'], r['logr'], ''))) # print nl return nl @@ -382,7 +383,8 @@ def readlog(self): # ,srcId,srcIdx): # returns list of log journal i # def next(self): # get next item from db in text format # n = self.result - # nl = "|".join(n.src, n['seq'], n['date'], n['band'], n['call'], n['rept'], n['powr'], n['oper'], n['logr']) + # nl = "|".join(n.src, n['seq'], n['date'], n['band'], n['call'], n['rept'], + # n['powr'], n['oper'], n['logr']) # return nl def log(self, n): # add item to journal logfile table (and other tables...) @@ -391,11 +393,14 @@ def log(self, n): # add item to journal logfile table (and other tables...) # self.sqdb.row_factory = sqlite3.Row # namedtuple_factory curs = sqdb.cursor() # make a database connection cursor # start commit, begin transaction - sql = "insert into qjournal (src,seq,date,band,call,rept,powr,oper,logr) values (?,?,?,?,?,?,?,?,?)" + sql = "insert into qjournal (src,seq,date,band,call,rept,powr,oper,logr)" \ + "values (?,?,?,?,?,?,?,?,?)" curs.execute(sql, parms) - # sql = "insert into qsos values (src,seq,date,band,call,sfx,rept,powr,oper,logr),(?,?,?,?,?,?,?,?,?,?)" + # sql = "insert into qsos values (src,seq,date,band,call,sfx,rept,powr,oper,logr), + # (?,?,?,?,?,?,?,?,?,?)" # self.cur(sql,parms) - # update qso count, scores? or just use q db count? this doesn't work well for different weights + # update qso count, scores? or just use q db count? this doesn't work well for + # different weights # update sequence counts for journals? sqdb.commit() # do the commit if n.band == '*QST': @@ -484,7 +489,8 @@ def cleanlog(self): # print "discarding out of date range",iv.date,iv.src,iv.seq del (d[i]) for i in d.values(): # re-index by call-band - dummy, dummy, dummy, dummy, call, dummy, dummy = self.qparse(i.call) # extract call (not /...) + dummy, dummy, dummy, dummy, call, dummy, dummy = self.qparse(i.call) + # extract call (not /...) k = "%s-%s" % (call, i.band) # filter out noncontest entries if ival(i.powr) == 0 and i.band[0] != '*': continue @@ -512,7 +518,8 @@ def prlogln(self, s): (s.date[4:11], s.band, s.call[:7], s.rept[:33], s.oper, s.logr, s.seq, s.src) else: ln = "%8s %5s %-11s %-24s %4s %-3s %-3s %4s %s" % \ - (s.date[4:11], s.band, s.call[:11], s.rept[:24], s.powr, s.oper, s.logr, s.seq, s.src) + (s.date[4:11], s.band, s.call[:11], s.rept[:24], s.powr, + s.oper, s.logr, s.seq, s.src) return ln def prlog(self): @@ -574,12 +581,14 @@ def vhf_cabrillo(self): l.sort() # sort data with prepended date.time for i in l: print i[13:] # rm sort key date.time - # added support for winter field day, this outputs the cabrillo format that is posted on their website. + # added support for winter field day, this outputs the Cabrillo format + # that is posted on their website. def winter_fd(self): - "output Winter Field day QSO data in cabrillo format:" + "output Winter Field Day QSO data in Cabrillo format:" # vars: - band_map = {'160': '1800', '80': '3500', '40': '7000', '20': '14000', '15': '21000', '10': '28000', '6': '50', - '2': '144', '220': '222', '440': '432', '900': '902', '1200': '1.2G'} + band_map = {'160': '1800', '80': '3500', '40': '7000', '20': '14000', '15': '21000', + '10': '28000', '6': '50', '2': '144', '220': '222', '440': '432', + '900': '902', '1200': '1.2G'} dummy, n, dummy = self.cleanlog() l = [] mycall = string.upper(GD.getv('fdcall')) @@ -604,7 +613,8 @@ def winter_fd(self): cat, sect = i.rept.split(" ") if '/' in call: # split off grid from call call, grid = call.split('/') - # cabrillo example: QSO: 40 DI 2019-01-19 1641 KC7SDA 1H WWA KZ9ZZZ 1H NFL + # cabrillo example: + # QSO: 40 DI 2019-01-19 1641 KC7SDA 1H WWA KZ9ZZZ 1H NFL l.append("%sQSO: %-5s %-2s %-10s %4s %-10s %-2s %-5s %-10s %-2s %-5s" % ( i.date, freq, mod, date, tim, mycall, mycat, mysect, call, cat, sect)) l.sort() # sort data with prepended date.time @@ -714,7 +724,8 @@ def postnewinfo(self, time, call, bandmod, report): def postnew(self, time, call, bandmod, report, oper, logr, powr): "post new locally generated info" s = self.new(NODE) - s.date, s.call, s.band, s.rept, s.oper, s.logr, s.powr = time, call, bandmod, report, oper, logr, powr + s.date, s.call, s.band, s.rept, s.oper, s.logr,\ + s.powr = time, call, bandmod, report, oper, logr, powr s.seq = -1 return s.dispatch('user') @@ -846,7 +857,8 @@ def bandrpt(self): digq += 1 if 'p' in i.band: fonq += 1 - return (qpb, ppb, qpop, qplg, qpst, tq, score, maxp, cwq, digq, fonq, qpgop, gotaq, nat, sat) + return (qpb, ppb, qpop, qplg, qpst, tq, score, maxp, + cwq, digq, fonq, qpgop, gotaq, nat, sat) def bands(self): """ .ba command band status station on, q/band, xx needs upgd""" @@ -980,8 +992,8 @@ def qparse(self, line): if tm: # if forced time exists if len(tm) < 7: # it must be complete stat = 0 - # print "stat[%s] time[%s] pfx[%s] sfx[%s] call[%s] xcall[%s] rpt[%s]"%\ - # (stat,tm,pfx,sfx,call,xcall,rept) + # print "stat[%s] time[%s] pfx[%s] sfx[%s] call[%s] xcall[%s] rpt[%s]"%\ + # (stat,tm,pfx,sfx,call,xcall,rept) return (stat, tm, pfx, sfx, call, xcall, rept) def dupck(self, wcall, band): @@ -1089,7 +1101,8 @@ def wasrpt(self): else: h.append("%s" % i) n.sort() - r.append("Worked All States Report\n%s Warning(s) Below\nNeed %s States:" % (len(e), len(n))) + r.append("Worked All States Report\n%s Warning(s) Below\nNeed %s States:" + % (len(e), len(n))) for i in n: r.append(i) h.sort() @@ -1248,7 +1261,8 @@ def nod_on_bands(self): class netsync: """network database synchronization""" - # removed netmask - it isn't used anywhere in the program from what I can tell (do a search for 'netmask' this is the only place you find it) + # removed netmask - it isn't used anywhere in the program from what I can tell + # (do a search for 'netmask' this is the only place you find it) # re-coded the ip address calculation to smooth it out and make it cross platform compatible # netmask = '255.255.255.0' rem_adr = "" # remote bc address @@ -1463,7 +1477,9 @@ def getv(self, name): return self.byname[name].val def sethelp(self): - l = [" Set Commands\n For the Logging Guru In Charge\n eg: .set \n"] # spaced for sort + l = [" Set Commands\n For the Logging Guru In Charge" + "\n eg: .set \n"] + # spaced for sort for i in self.byname.keys(): if i[:2] != 'p:': # skip ops in help display l.append(" %-6s %-43s '%s'" % (i, self.byname[i].desc, self.byname[i].val)) @@ -1472,7 +1488,8 @@ def sethelp(self): # modifed the sect setting regex to accept both lower and upper case -# added additional form fields (also fixed 'from' to 'form') for wfd NOTE: set commands have a max length of 6! +# added additional form fields (also fixed 'from' to 'form') for wfd +# NOTE: set commands have a max length of 6! GD = global_data() for name, desc, default, okre, maxlen in ( ('class', ' FD class (eg 2A)', '2A', r'[1-9][0-9]?[a-fihoA-FIHO]$', 3), @@ -1775,7 +1792,8 @@ def contestlog(pr): if natural_q >= 5: natural_bp = 100 tot_bonus += natural_bp - print " %3s Five Alternate power QSOs completed (%s/5) (list below)" % (natural_bp, natural_q) + print " %3s Five Alternate power QSOs completed (%s/5) (list below)"\ + % (natural_bp, natural_q) w1aw_msg_bp = 0 if len(w1aw_msg) > 30: # ignore short file place holder 152i w1aw_msg_bp = 100 @@ -1785,12 +1803,14 @@ def contestlog(pr): if GD.getv('svego') > "": site_visited_ego_bp = 100 tot_bonus += site_visited_ego_bp - print " %3s Site Visited by elected govt officials (%s)" % (site_visited_ego_bp, GD.getv('svego')) + print " %3s Site Visited by elected govt officials (%s)"\ + % (site_visited_ego_bp, GD.getv('svego')) site_visited_roa_bp = 0 if GD.getv('svroa') > "": site_visited_roa_bp = 100 tot_bonus += site_visited_roa_bp - print " %3s Site Visited by representative of agency (%s)" % (site_visited_roa_bp, GD.getv('svroa')) + print " %3s Site Visited by representative of agency (%s)"\ + % (site_visited_roa_bp, GD.getv('svroa')) gota_max_bp = 0 if gotaq >= 100: gota_max_bp = 100 @@ -2113,7 +2133,8 @@ def dialog(self): fr1 = Frame(s.t) fr1.grid(row=0, column=0) Label(fr1, text='Initials ', font=FDBFONT).grid(row=0, column=0, sticky=W) - s.initials = Entry(fr1, width=3, font=FDBFONT, validate='focusout', validatecommand=s.lookup) + s.initials = Entry(fr1, width=3, font=FDBFONT, + validate='focusout', validatecommand=s.lookup) s.initials.grid(row=0, column=1, sticky=W) s.initials.focus() Label(fr1, text='Name', font=FDBFONT).grid(row=1, column=0, sticky=W) @@ -2131,9 +2152,12 @@ def dialog(self): fr2 = Frame(s.t) fr2.grid(row=1, column=0, sticky=EW, pady=3) fr2.grid_columnconfigure((0, 1), weight=1) - Label(fr2, text='=Save', font=FDBFONT, foreground='red').grid(row=3, column=0, sticky=W) - # Button(fr2, text='Save', font=fdbfont, command=s.applybtn) .grid(row=3, column=1, sticky=EW, padx=3) - Button(fr2, text='Dismiss', font=FDBFONT, command=s.quitbtn).grid(row=3, column=2, sticky=EW, padx=3) + Label(fr2, text='=Save', font=FDBFONT, + foreground='red').grid(row=3, column=0, sticky=W) + # Button(fr2, text='Save', font=fdbfont, + # command=s.applybtn) .grid(row=3, column=1, sticky=EW, padx=3) + Button(fr2, text='Dismiss', font=FDBFONT, + command=s.quitbtn).grid(row=3, column=2, sticky=EW, padx=3) # Bound enter key to save entries s.t.bind('', lambda event: s.applybtn) @@ -2146,7 +2170,8 @@ def lookup(self): self.initials.focus() else: self.initials.configure(bg='white') - dummy, name, call, age, vist = string.split(PARTICIPANTS.get(initials, ', , , , '), ', ') + dummy, name, call, age, vist =\ + string.split(PARTICIPANTS.get(initials, ', , , , '), ', ') self.name.delete(0, END) self.name.insert(END, name) self.call.delete(0, END) @@ -2262,7 +2287,8 @@ def setnode(new): NODE = string.lower(new) QDB.redup() renew_title() - LBLNODE.configure(text="My Node: %s" % NODE, font=FDFONT, foreground='royalblue', background='lightgrey') + LBLNODE.configure(text="My Node: %s" % NODE, font=FDFONT, + foreground='royalblue', background='lightgrey') # Had to add the above so that the new lblnode could be updated @@ -2380,7 +2406,8 @@ def viewwasrpt(): def updatebb(): """update band buttons""" # Added Who's on the bands functionality with a mouse over event - # Tried and tried to get wof to return only one result for the mouse over. If you can, you're awesome! + # Tried and tried to get wof to return only one result for the mouse over. + # If you can, you're awesome! global WOF r, cl, vh, go = NET.si.nod_on_bands() anytext = "VHF " @@ -2393,7 +2420,8 @@ def whosonfirst(event): dummy, dummy, age = d.get(t.nod, ('', '', 9999)) if age > t.age: d[t.nod] = (t.bnd, t.msc, t.age) for t in d: - TXTBILLB.insert(END, "%8s %4s %-18s %4s\n" % (t, d[t][0], d[t][1], d[t][2])) # t.bnd,t.msc,t.age) + TXTBILLB.insert(END, "%8s %4s %-18s %4s\n" % (t, d[t][0], d[t][1], d[t][2])) + # t.bnd,t.msc,t.age) topper() TXTBILLB.see(END) @@ -2475,8 +2503,8 @@ def whosonsecond(event): def updateqct(): "update contact count" - dummy, dummy, qpop, qplg, dummy, dummy, dummy, dummy, cwq, digq, fonq, dummy, gotaq, dummy, dummy = \ - QDB.bandrpt() # xx reduce processing here + dummy, dummy, qpop, qplg, dummy, dummy, dummy, dummy, cwq, digq, fonq,\ + dummy, gotaq, dummy, dummy = QDB.bandrpt() # xx reduce processing here for i, j in (('FonQ', 'Phone %5s' % fonq), ('CW/D', 'CW&Dig %4s' % (cwq + digq)), ('GOTAq', 'GOTA %6s' % gotaq)): @@ -2546,14 +2574,15 @@ def BandButtons(w): bm = "%s%s" % (i, j) if i == 'off': bm = 'off' - # indicatoron = 0 makes square button with text inside but doesn't work well on mac, with value 1 it makes a - # circle alongside the text and works on both so detect mac and change it for mac only - BANDB[bm] = Radiobutton(master=w, text=bm, font=FDFONT, background='lightgrey', indicatoron=mac, \ - variable=SV, value=bm, selectcolor='pink2', + # indicatoron = 0 makes square button with text inside but doesn't work well on mac, + # with value 1 it makes a circle alongside the text and works on both so detect mac + # and change it for mac only + BANDB[bm] = Radiobutton(master=w, text=bm, font=FDFONT, background='lightgrey', + indicatoron=mac, variable=SV, value=bm, selectcolor='pink2', command=lambda b=bm: (bandset(b))) else: - BANDB[bm] = Radiobutton(master=w, text=bm, font=FDFONT, background='pink2', indicatoron=mac, \ - variable=SV, value=bm, selectcolor='white', + BANDB[bm] = Radiobutton(master=w, text=bm, font=FDFONT, background='pink2', + indicatoron=mac, variable=SV, value=bm, selectcolor='white', command=lambda b=bm: (bandset(b))) BANDB[bm].grid(row=b, column=a, sticky=NSEW) b += 1 @@ -2630,7 +2659,8 @@ def testqgen(n): print " (7 characters}" k = string.lower(string.strip(sys.stdin.readline())[:8]) if len(k) == 8: - print "That's too many.. (Marc? is that you?)" # Thanks to Marc Fountain K9MAF for the correction. + print "That's too many.. (Marc? is that you?)" + # Thanks to Marc Fountain K9MAF for the correction. k = k[:7] Z = len(k) if k != 'gota': @@ -2730,15 +2760,21 @@ def testqgen(n): RESOURCEMENU = Menu(MENU, tearoff=0) MENU.add_cascade(label="Resources", menu=RESOURCEMENU) # Changed this from fdrules to just Rules to get away from fd name in file folder -RESOURCEMENU.add_command(label="ARRL FD Rules (pdf)", command=lambda: os.startfile('Rules.pdf')) +RESOURCEMENU.add_command(label="ARRL FD Rules (pdf)", + command=lambda: os.startfile('Rules.pdf')) # Changed this to a .dat file to remove the duplicate txt file -RESOURCEMENU.add_command(label="ARRL Sections", command=lambda: viewtextf('Arrl_sect.dat', 'ARRL Sections')) -RESOURCEMENU.add_command(label="ARRL Band Chart (pdf)", command=lambda: os.startfile('Bands.pdf')) -RESOURCEMENU.add_command(label="ARRL Band Plan", command=lambda: viewtextf('ARRL_Band_Plans.txt', "ARRL Band Plan")) +RESOURCEMENU.add_command(label="ARRL Sections", + command=lambda: viewtextf('Arrl_sect.dat', 'ARRL Sections')) +RESOURCEMENU.add_command(label="ARRL Band Chart (pdf)", + command=lambda: os.startfile('Bands.pdf')) +RESOURCEMENU.add_command(label="ARRL Band Plan", + command=lambda: viewtextf('ARRL_Band_Plans.txt', "ARRL Band Plan")) # This is not needed with the band chart giving the same info -# resourcemenu.add_command(label="FD Frequency List", command=lambda: viewtextf('frequencies.txt', "FD Frequency List")) +# resourcemenu.add_command(label="FD Frequency List", +# command=lambda: viewtextf('frequencies.txt', "FD Frequency List")) # Removed the propagation report. We don't use it -# resourcemenu.add_command(label="Propagation Info", command=lambda: viewtextf('propagation.txt', "Propagation Info")) +# resourcemenu.add_command(label="Propagation Info", +# command=lambda: viewtextf('propagation.txt', "Propagation Info")) # Created a W1AW menu W1AWMENU = Menu(MENU, tearoff=0) MENU.add_cascade(label="W1AW", menu=W1AWMENU) @@ -2761,7 +2797,8 @@ def testqgen(n): x = e + 100 if (x < 0): x += 2400 TZCHART += "%04d %04d %04d %04d %04d\n" % (g, p, c, e, x) -RESOURCEMENU.add_command(label="Time Conversion Chart", command=lambda: viewtextv(TZCHART, "Time Conversion Chart")) +RESOURCEMENU.add_command(label="Time Conversion Chart", + command=lambda: viewtextv(TZCHART, "Time Conversion Chart")) HELPMENU = Menu(MENU, tearoff=0) MENU.add_cascade(label="Help", menu=HELPMENU) HELPMENU.add_command(label="Quick Help", command=lambda: viewtextf('Keyhelp.txt')) @@ -2964,7 +3001,8 @@ def setpwr(p): PWRMU.add_command(label=' 50W Natural', command=lambda: (setpwr('50n'))) PWRMU.add_command(label=' 100W Natural', command=lambda: (setpwr('100n'))) PWRMU.add_command(label=' 150W Natural', command=lambda: (setpwr('150n'))) -PWRNT = Entry(F1B, width=4, font=FDFONT, background=PCOLOR, validate='focusout', validatecommand=ckpowr) +PWRNT = Entry(F1B, width=4, font=FDFONT, + background=PCOLOR, validate='focusout', validatecommand=ckpowr) PWRNT.grid(row=0, column=7, sticky=NSEW) POWLBL = Label(F1B, text="W", font=FDFONT, background=PCOLOR) POWLBL.grid(row=0, column=8, sticky=NSEW) @@ -2978,13 +3016,15 @@ def setpwr(p): LBLNET = Label(F1B, text="Network Status", font=FDFONT, foreground='royalblue', background='gold') LBLNET.grid(row=2, column=0, columnspan=9, sticky=NSEW) # Node window -LBLNODE = Label(F1B, text="My Node: %s" % NODE, font=FDFONT, foreground='royalblue', background='lightgrey') +LBLNODE = Label(F1B, text="My Node: %s" % NODE, font=FDFONT, + foreground='royalblue', background='lightgrey') LBLNODE.grid(row=2, column=9, columnspan=1, sticky=NSEW) # Whos on First Window to display operators on bands # lblwof = Label(f1b, text="", font=fdfont, foreground='royalblue', background='lightgrey') # lblwof.grid(row=2, column=0, columnspan=9, sticky=NSEW) # Port window -# lblport = Label(f1b, text="Port: %s" % port_base, font=fdfont, foreground='royalblue', background='lightgrey') +# lblport = Label(f1b, text="Port: %s" % port_base, font=fdfont, +# foreground='royalblue', background='lightgrey') # lblport.grid(row=3, column=9, columnspan=1, sticky=NSEW) # log window LOGW = Text(ROOT, takefocus=0, height=11, width=80, font=FDMFONT, @@ -3055,11 +3095,18 @@ def setpwr(p): ROOT.deiconify() NET.start() # start threads renew_title() -TXTBILLB.insert(END, " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", ("b")) -TXTBILLB.insert(END, " Dialogue Window\n", ("b")) -TXTBILLB.insert(END, " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n", ("b")) -TXTBILLB.insert(END, "Please select the Operator, Logger, Power and Band/Mode in pink above.\n\n") -TXTBILLB.insert(END, "-Call-Class-Sect- \n") +TXTBILLB.insert(END, + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", + ("b")) +TXTBILLB.insert(END, + " Dialogue Window\n", ("b")) +TXTBILLB.insert(END, + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n", + ("b")) +TXTBILLB.insert(END, + "Please select the Operator, Logger, Power and Band/Mode in pink above.\n\n") +TXTBILLB.insert(END, + "-Call-Class-Sect- \n") TXTBILLB.config(insertwidth=3) TXTBILLB.focus_set() @@ -3125,7 +3172,8 @@ def proc_key(ch): mhelp() return # Adding a statement to check for uppercase. Previously unresponsive while capped locked - # Thanks to WW9A Brian Smith for pointing out that the program isn't randomly frozen and not requiring a restart. + # Thanks to WW9A Brian Smith for pointing out that the program isn't randomly frozen + # and not requiring a restart. if ch.isupper(): TXTBILLB.insert(END, " LOWERCAPS PLEASE \n") KBUF = "" @@ -3250,8 +3298,9 @@ def proc_key(ch): return if re.match(r'[.]re$', KBUF): # report xx mv to gui print - print " band cw q pwr dig q pwr fon q pwr" - qpb, ppb, dummy, dummy, dummy, tq, score, maxp, dummy, dummy, dummy, dummy, dummy, dummy, dummy = QDB.bandrpt() + print " band cw q pwr dig q pwr fon q pwr", qpb, ppb, dummy, dummy, + dummy, tq, score, maxp, dummy, dummy, dummy, dummy, dummy, dummy,\ + dummy = QDB.bandrpt() for b in (160, 80, 40, 20, 15, 10, 6, 2, 220, 440, 1200, 'sat', 'gota'): print "%6s" % b, for m in 'cdp': @@ -3327,7 +3376,9 @@ def proc_key(ch): rept1 = string.upper(rept) if clas == '1D': if clas in rept1: - TXTBILLB.insert(END, "\n 1D to 1D contacts are logged, but zero points! \n") + TXTBILLB.insert(END, + "\n 1D to 1D contacts are logged, but zero points!" + " \n") topper() # check the report for valid fd or wfd classes: # note according to the cheat sheet, \d is a digit @@ -3344,7 +3395,9 @@ def proc_key(ch): # allow everything m = "something" if m == None: # match failed, do not allow and abort logging - TXTBILLB.insert(END, " - ERROR: Bad exchange ( %s ) Please Try Again\n" % rept) + TXTBILLB.insert(END, + " - ERROR: Bad exchange ( %s ) Please Try Again\n" + % rept) topper() return # Check for valid section in report @@ -3507,7 +3560,8 @@ def __init__(self, parent, node, seq): # self.transient(parent) # avoid showing as separate item self.crazytxt.set('Edit Log Entry') self.crazyclr.set('lightgrey') - self.crazylbl = tl = Label(top, text=self.crazytxt.get(), font=FDBFONT, bg=self.crazyclr.get(), relief=RAISED) + self.crazylbl = tl = Label(top, text=self.crazytxt.get(), font=FDBFONT, + bg=self.crazyclr.get(), relief=RAISED) # tl = Label(top, text='Edit Log Entry', font=fdbfont, bg='lightgrey', relief=RAISED) tl.grid(row=0, columnspan=2, sticky=EW) tl.grid_columnconfigure(0, weight=1)