<commit_before>"""
Check the status of our AWOS sites being offline or online
run from RUN_10_AFTER.sh
"""
import tracker
track = tracker.Engine()
import access
import network
nt = network.Table("AWOS")
import iemdb
IEM = iemdb.connect('iem', bypass=True)
icursor = IEM.cursor()
import mx.DateTime

offline = {}
icursor.execute("""SELECT station, valid from offline 
    WHERE network IN ('AWOS')""")
for row in icursor:
    offline[ row[0] ] = row[1]

thres = mx.DateTime.now() - mx.DateTime.RelativeDateTime(hours=1)

obs = access.get_network("AWOS", IEM)
actions = 0
for sid in obs.keys():
    ob = obs[sid]
    # back online!
    if ob.data['ts'] > thres and offline.has_key(sid):
        actions += 1
        track.checkStation(sid, {'ts': ob.data['ts'], 
                                 'sname': nt.sts[sid]['name']}, 
                           'AWOS', 'iaawos', False)
    elif ob.data['ts'] < thres and not offline.has_key(sid):
        actions += 1
        track.doAlert(sid, {'ts': ob.data['ts'], 
                                 'sname': nt.sts[sid]['name']}, 
                           'AWOS', 'iaawos', False)

print actions
if actions < 10:
    track.send()<commit_msg>remove debug statement<commit_after>"""
Check the status of our AWOS sites being offline or online
run from RUN_10_AFTER.sh
"""
import tracker
track = tracker.Engine()
import access
import network
nt = network.Table("AWOS")
import iemdb
IEM = iemdb.connect('iem', bypass=True)
icursor = IEM.cursor()
import mx.DateTime

offline = {}
icursor.execute("""SELECT station, valid from offline 
    WHERE network IN ('AWOS')""")
for row in icursor:
    offline[ row[0] ] = row[1]

thres = mx.DateTime.now() - mx.DateTime.RelativeDateTime(hours=1)

obs = access.get_network("AWOS", IEM)
actions = 0
for sid in obs.keys():
    ob = obs[sid]
    # back online!
    if ob.data['ts'] > thres and offline.has_key(sid):
        actions += 1
        track.checkStation(sid, {'ts': ob.data['ts'], 
                                 'sname': nt.sts[sid]['name']}, 
                           'AWOS', 'iaawos', False)
    elif ob.data['ts'] < thres and not offline.has_key(sid):
        actions += 1
        track.doAlert(sid, {'ts': ob.data['ts'], 
                                 'sname': nt.sts[sid]['name']}, 
                           'AWOS', 'iaawos', False)

if actions < 10:
    track.send()
{'fraction_non_alphanumeric': 0.15111861544955676, 'fraction_numerical': 0.008442380751371888, 'mean_word_length': 2.511111111111111, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1761236', 'n_tokens_mistral': 802, 'n_tokens_neox': 757, 'n_words': 207}