diff --git a/web/app.py b/web/app.py index 4d532de..7a79745 100644 --- a/web/app.py +++ b/web/app.py @@ -47,61 +47,58 @@ from gen_script_template import gen_script import os, ast ##import hb_config -from hws.misc_functions import * -from hws.views import * - script_links = {} active_tgs = {} ping_list = {} peer_locations = {} -### Query radioid.net for list of IDs -##def get_ids(callsign): -## try: -## url = "https://www.radioid.net" -## response = requests.get(url+"/api/dmr/user/?callsign=" + callsign) -## result = response.json() -#### print(result) -## # id_list = [] -## id_list = {} -## f_name = result['results'][0]['fname'] -## l_name = result['results'][0]['surname'] -## try: -## city = str(result['results'][0]['city'] + ', ' + result['results'][0]['state'] + ', ' + result['results'][0]['country']) -## except: -## city = result['results'][0]['country'] -## for i in result['results']: -## id_list[i['id']] = 0 -## return str([id_list, f_name, l_name, city]) -## except: -## return str([{}, '', '', '']) -## -## -### Return string in NATO phonetics -##def convert_nato(string): -## d_nato = { 'A': 'ALPHA', 'B': 'BRAVO', 'C': 'CHARLIE', 'D': 'DELTA', -## 'E': 'ECHO', 'F': 'FOXTROT', 'G': 'GOLF', 'H': 'HOTEL', -## 'I': 'INDIA', 'J': 'JULIETT','K': 'KILO', 'L': 'LIMA', -## 'M': 'MIKE', 'N': 'NOVEMBER','O': 'OSCAR', 'P': 'PAPA', -## 'Q': 'QUEBEC', 'R': 'ROMEO', 'S': 'SIERRA', 'T': 'TANGO', -## 'U': 'UNIFORM', 'V': 'VICTOR', 'W': 'WHISKEY', 'X': 'X-RAY', -## 'Y': 'YANKEE', 'Z': 'ZULU', '0': 'zero(0)', '1': 'one(1)', -## '2': 'two(2)', '3': 'three(3)', '4': 'four(4)', '5': 'five(5)', -## '6': 'six(6)', '7': 'seven(7)', '8': 'eight(8)', '9': 'nine(9)', -## 'a': 'alpha', 'b': 'bravo', 'c': 'charlie', 'd': 'delta', -## 'e': 'echo', 'f': 'foxtrot', 'g': 'golf', 'h': 'hotel', -## 'i': 'india', 'j': 'juliett','k': 'kilo', 'l': 'lima', -## 'm': 'mike', 'n': 'november','o': 'oscar', 'p': 'papa', -## 'q': 'quebec', 'r': 'romeo', 's': 'sierra', 't': 'tango', -## 'u': 'uniform', 'v': 'victor', 'w': 'whiskey', 'x': 'x-ray', -## 'y': 'yankee', 'z': 'Zulu'} -## ns = '' -## for c in string: -## try: -## ns = ns + d_nato[c] + ' ' -## except: -## ns = ns + c + ' ' -## return ns +# Query radioid.net for list of IDs +def get_ids(callsign): + try: + url = "https://www.radioid.net" + response = requests.get(url+"/api/dmr/user/?callsign=" + callsign) + result = response.json() +## print(result) + # id_list = [] + id_list = {} + f_name = result['results'][0]['fname'] + l_name = result['results'][0]['surname'] + try: + city = str(result['results'][0]['city'] + ', ' + result['results'][0]['state'] + ', ' + result['results'][0]['country']) + except: + city = result['results'][0]['country'] + for i in result['results']: + id_list[i['id']] = 0 + return str([id_list, f_name, l_name, city]) + except: + return str([{}, '', '', '']) + + +# Return string in NATO phonetics +def convert_nato(string): + d_nato = { 'A': 'ALPHA', 'B': 'BRAVO', 'C': 'CHARLIE', 'D': 'DELTA', + 'E': 'ECHO', 'F': 'FOXTROT', 'G': 'GOLF', 'H': 'HOTEL', + 'I': 'INDIA', 'J': 'JULIETT','K': 'KILO', 'L': 'LIMA', + 'M': 'MIKE', 'N': 'NOVEMBER','O': 'OSCAR', 'P': 'PAPA', + 'Q': 'QUEBEC', 'R': 'ROMEO', 'S': 'SIERRA', 'T': 'TANGO', + 'U': 'UNIFORM', 'V': 'VICTOR', 'W': 'WHISKEY', 'X': 'X-RAY', + 'Y': 'YANKEE', 'Z': 'ZULU', '0': 'zero(0)', '1': 'one(1)', + '2': 'two(2)', '3': 'three(3)', '4': 'four(4)', '5': 'five(5)', + '6': 'six(6)', '7': 'seven(7)', '8': 'eight(8)', '9': 'nine(9)', + 'a': 'alpha', 'b': 'bravo', 'c': 'charlie', 'd': 'delta', + 'e': 'echo', 'f': 'foxtrot', 'g': 'golf', 'h': 'hotel', + 'i': 'india', 'j': 'juliett','k': 'kilo', 'l': 'lima', + 'm': 'mike', 'n': 'november','o': 'oscar', 'p': 'papa', + 'q': 'quebec', 'r': 'romeo', 's': 'sierra', 't': 'tango', + 'u': 'uniform', 'v': 'victor', 'w': 'whiskey', 'x': 'x-ray', + 'y': 'yankee', 'z': 'Zulu'} + ns = '' + for c in string: + try: + ns = ns + d_nato[c] + ' ' + except: + ns = ns + c + ' ' + return ns # Class-based application configuration class ConfigClass(object): @@ -665,108 +662,108 @@ def create_app(): db.session.commit() -## # The Home page is accessible to anyone -## @app.route('/') -## def home_page(): -## home_text = Misc.query.filter_by(field_1='home_page').first() -## #content = Markup('Index') -## try: -## l_news = News.query.order_by(News.time.desc()).first() -## content = ''' -## -##
-##''' + l_news.date + ''' - -##
-## -##
''' + l[1][0] + ''' |
-##
DMR ID: | -##''' + str(l[0]) + ''' | -##
Location: | -##''' + l[1][5] + ''' | -##
Lat, Lon: | -##''' + l[1][1] + ''', ''' + l[1][2] + ''' | -##
Description: | -##''' + l[1][4] + ''' | -##
URL: -## |
-##''' + l[1][3] + ''' | -##
Device: | -##''' + l[1][6] + ''' | -##
''' + l[1][0] + ''' |
+
DMR ID: | +''' + str(l[0]) + ''' | +
Location: | +''' + l[1][5] + ''' | +
Lat, Lon: | +''' + l[1][1] + ''', ''' + l[1][2] + ''' | +
Description: | +''' + l[1][4] + ''' | +
URL: + |
+''' + l[1][3] + ''' | +
Device: | +''' + l[1][6] + ''' | +