diff --git a/web/app.py b/web/app.py index 6a9fe2e..ce1c81f 100644 --- a/web/app.py +++ b/web/app.py @@ -42,10 +42,7 @@ from socket import gethostbyname import re import folium -try: - from gen_script_template import gen_script -except: - pass +from gen_script_template import gen_script import os, ast ##import hb_config @@ -702,7 +699,7 @@ def create_app(): @app.route('/map') @login_required def map_page(): - f_map = folium.Map(location=[45.372, -121.6972], zoom_start=7) + f_map = folium.Map(location=center_map, zoom_start=map_zoom) ## folium.Marker([45.372, -121.6972], popup="hello", icon=folium.Icon(color="red", icon="record"), tooltip='hi').add_to(f_map) for l in peer_locations.items(): folium.Marker([float(l[1][1]), float(l[1][2])], popup=''' @@ -723,7 +720,7 @@ def create_app(): ''', icon=folium.Icon(color="red", icon="record"), tooltip='' + l[1][0] + '').add_to(f_map) content = f_map._repr_html_() - return render_template('flask_user_layout.html', markup_content = Markup(content)) + return render_template('map.html', markup_content = Markup(content)) @app.route('/help') def help_page(): @@ -734,50 +731,30 @@ def create_app(): def gen_pi_star(): try: u = current_user - ## print(u.username) id_dict = ast.literal_eval(u.dmr_ids) #u = User.query.filter_by(username=user).first() - ## print(user_id) ## print(request.args.get('mode')) ## if request.args.get('mode') == 'generated': - content = ''' -
-Pi-Star Instructions-- 1: Log into your Pi-Star device. rpi-rw-
sudo su -- Note: Link can be used only once. To run the script again, simply reload the page and paste a new command into the command line. - -''' + content = '' for i in id_dict.items(): #if i[1] == '': link_num = str(random.randint(1,99999999)).zfill(8) + str(time.time()) + str(random.randint(1,99999999)).zfill(8) script_links[i[0]] = link_num - content = content + '''\n -DMR ID: ''' + str(i[0]) + ''': -
+ content = content + ''' +
+
'''
#else:
# content = content + '''\nID: ''' + str(i[0]) + '''rpi-rw; wget -O /root/auto_pistar.py "''' + str(url) + '/get_script?dmr_id=' + str(i[0]) + '&number=' + str(link_num) + '''"; chmod +x /root/auto_pistar.py; python3 /root/auto_pistar.py; pistar-update Error ''' - content = content + '''\n |
-
''' + except: content = Markup('No DMR IDs found or other error.') #return str(content) - return render_template('flask_user_layout.html', markup_content = Markup(content)) + return render_template('pi-star_gen.html', markup_content = Markup(content)) @@ -829,16 +806,11 @@ def create_app(): ''' try: - #content = Markup('The HTML String') #user_id = request.args.get('user_id') u = current_user - ## print(u.username) id_dict = ast.literal_eval(u.dmr_ids) #u = User.query.filter_by(username=user).first() - ## print(user_id) - ## print(request.args.get('mode')) ## if request.args.get('mode') == 'generated': - #print(id_dict) content = '\n' for i in id_dict.items(): @@ -1342,6 +1314,11 @@ def create_app(): number = float(request.args.get('number')) #print(type(script_links[dmr_id])) u = User.query.filter(User.dmr_ids.contains(request.args.get('dmr_id'))).first() + + pub_list = [] + + + #print(u.dmr_ids) if authorized_peer(dmr_id)[1] == 0: @@ -1350,13 +1327,29 @@ def create_app(): passphrase = gen_passphrase(dmr_id) elif authorized_peer(dmr_id)[1] == '': passphrase = legacy_passphrase - print(passphrase) elif authorized_peer(dmr_id)[1] != '' or authorized_peer(dmr_id)[1] != 0: passphrase = authorized_peer(dmr_id)[1] #try: if dmr_id in script_links and number == float(script_links[dmr_id]): script_links.pop(dmr_id) - return str(gen_script(dmr_id, passphrase)) + + ml = MasterList.query.filter_by(public_list=True).filter_by(active=True).all() + pl = ProxyList.query.filter_by(public_list=True).filter_by(active=True).all() +## print(ml) + for m in ml: +## print(m.name) +## print(m.server) +## print(m.port) +## print(m.enable_um) +## print(m.passphrase) + sl = ServerList.query.filter_by(name=m.server).first() +## print(sl.ip) + if m.enable_um == True: + passp = passphrase + pub_list.append([m.server + '_' + m.name, sl.ip, passphrase, m.port]) + + + return str(gen_script(dmr_id, pub_list)) #except: #else: #content = 'Link used or other error.' @@ -2196,8 +2189,8 @@ TG #: ''' + str(tg_d.tg) + '''