update emergency function
This commit is contained in:
parent
d84e937c1f
commit
3368683a1f
@ -185,11 +185,15 @@ def dashboard_bb_write(call, dmr_id, time, bulletin):
|
||||
#logger.info(dash_bb)
|
||||
|
||||
def sos_write(dmr_id, time, message):
|
||||
user_settings = ast.literal_eval(os.popen('cat ./user_settings.txt').read())
|
||||
user_settings = ast.literal_eval(os.popen('cat ./user_settings.txt').read())
|
||||
try:
|
||||
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_settings[dmr_id][1]['ssid']
|
||||
if user_settings[dmr_id][1]['ssid'] == '':
|
||||
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_ssid
|
||||
else:
|
||||
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_settings[dmr_id][1]['ssid']
|
||||
except:
|
||||
sos_call = str(get_alias((dmr_id), subscriber_ids))
|
||||
|
||||
sos_info = {'call': sos_call, 'dmr_id': dmr_id, 'time': time, 'message':message}
|
||||
with open("/tmp/gps_data_user_sos.txt", 'w') as sos_file:
|
||||
sos_file.write(str(sos_info))
|
||||
@ -277,7 +281,7 @@ def process_sms(_rf_src, sms):
|
||||
logger.info(error_exception)
|
||||
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
|
||||
elif '@SOS' in sms:
|
||||
sos_write(int_id(_rf_src), 'time', sms)
|
||||
sos_write(int_id(_rf_src), time.strftime('%H:%M:%S - %m/%d/%y'), sms)
|
||||
elif '@REM SOS' == sms:
|
||||
os.remove('/tmp/gps_data_user_sos.txt')
|
||||
logger.info('Removing SOS')
|
||||
|
@ -180,7 +180,10 @@ def dashboard_bb_write(call, dmr_id, time, bulletin):
|
||||
def sos_write(dmr_id, time, message):
|
||||
user_settings = ast.literal_eval(os.popen('cat ./user_settings.txt').read())
|
||||
try:
|
||||
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_settings[dmr_id][1]['ssid']
|
||||
if user_settings[dmr_id][1]['ssid'] == '':
|
||||
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_ssid
|
||||
else:
|
||||
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_settings[dmr_id][1]['ssid']
|
||||
except:
|
||||
sos_call = str(get_alias((dmr_id), subscriber_ids))
|
||||
sos_info = {'call': sos_call, 'dmr_id': dmr_id, 'time': time, 'message':message}
|
||||
@ -270,7 +273,7 @@ def process_sms(_rf_src, sms):
|
||||
logger.info(error_exception)
|
||||
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
|
||||
elif '@SOS' in sms:
|
||||
sos_write(int_id(_rf_src), 'time', sms)
|
||||
sos_write(int_id(_rf_src), time.strftime('%H:%M:%S - %m/%d/%y'), sms)
|
||||
elif '@REM SOS' == sms:
|
||||
os.remove('/tmp/gps_data_user_sos.txt')
|
||||
logger.info('Removing SOS')
|
||||
|
@ -140,6 +140,7 @@ def check_emergency():
|
||||
</table>
|
||||
<p> </p>
|
||||
<button onclick="window.open('view_map?track=""" + sos_file['call'] + """&reload=30','_blank' );" type="button" class="emergency_button"><h1>View Station on Map</h1></button>
|
||||
<p style="text-align: center;"><a href="https://aprs.fi/""" + sos_file['call'] + """"><strong>View on aprs.fi</strong></a></p>
|
||||
<hr />
|
||||
|
||||
""")
|
||||
@ -296,23 +297,25 @@ def map():
|
||||
|
||||
@app.route('/bulletin_rss.xml')
|
||||
def bb_rss():
|
||||
#return render_template('map.html', title = dashboard_title, logo = logo)
|
||||
dash_bb = ast.literal_eval(os.popen('cat /tmp/gps_data_user_bb.txt').read())
|
||||
post_data = ''
|
||||
rss_header = """<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>""" + dashboard_title + """ - Bulletin Board Feed</title>
|
||||
<link>""" + rss_link + """</link>
|
||||
<description>This is the Bulletin Board feed from """ + dashboard_title + """</description>"""
|
||||
for entry in dash_bb:
|
||||
post_data = post_data + """
|
||||
<item>
|
||||
<title>""" + entry['call'] + ' - ' + str(entry['dmr_id']) + """</title>
|
||||
<link>""" + rss_link + """</link>
|
||||
<description>""" + entry['bulletin'] + """ - """ + entry['time'] + """</description>
|
||||
</item>
|
||||
"""
|
||||
return Response(rss_header + post_data + "</channel>\n</rss>", mimetype='text/xml')
|
||||
try:
|
||||
dash_bb = ast.literal_eval(os.popen('cat /tmp/gps_data_user_bb.txt').read())
|
||||
post_data = ''
|
||||
rss_header = """<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>""" + dashboard_title + """ - Bulletin Board Feed</title>
|
||||
<link>""" + rss_link + """</link>
|
||||
<description>This is the Bulletin Board feed from """ + dashboard_title + """</description>"""
|
||||
for entry in dash_bb:
|
||||
post_data = post_data + """
|
||||
<item>
|
||||
<title>""" + entry['call'] + ' - ' + str(entry['dmr_id']) + """</title>
|
||||
<link>""" + rss_link + """</link>
|
||||
<description>""" + entry['bulletin'] + """ - """ + entry['time'] + """</description>
|
||||
</item>
|
||||
"""
|
||||
return Response(rss_header + post_data + "\n</channel>\n</rss>", mimetype='text/xml')
|
||||
except:
|
||||
return str('<h1 style="text-align: center;">No data</h1>')
|
||||
if __name__ == '__main__':
|
||||
app.run(debug = True, port=dash_port, host=dash_host)
|
||||
|
Loading…
Reference in New Issue
Block a user