Skip to content

Instantly share code, notes, and snippets.

@hyakuhei
Created January 27, 2014 22:37
Show Gist options
  • Save hyakuhei/8658747 to your computer and use it in GitHub Desktop.
Save hyakuhei/8658747 to your computer and use it in GitHub Desktop.
def getStation(address):
#ƒunction to take in a RIC code and return some meaningful string
return 'Unknown'
f = subprocess.Popen(['tail','-F','multi.log'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
prev_address = ''
while True:
line = f.stdout.readline()
if not line.startswith('POCSAG512:'):
#Skip to the next line
continue
if 'CORRUPT' in line:
continue
if 'Address' in line:
prev_address = line.split(' ')[2]
continue
if 'Alpha' in line:
d = datetime.datetime.now()
nowstr = "%s/%s/%s %s:%s:%s" % (d.year,d.month,d.day,d.hour,d.minute,d.second)
addr = getStation(prev_address)
message = " ".join(line.split(' ')[2:])
message = message.strip()
if message.endswith('<NUL>'):
message = message[:-5]
print "%s\t%s\t%s" % (addr,nowstr,message)
continue
prev_address = ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment