fix templates, continue tiny pages, continue data gateway
This commit is contained in:
parent
bb8763bd45
commit
4633f4d518
110
data_gateway.py
110
data_gateway.py
@ -998,45 +998,74 @@ def send_sms(csbk, to_id, from_id, peer_id, call_type, msg):
|
|||||||
def data_que_check():
|
def data_que_check():
|
||||||
l=task.LoopingCall(data_que_send)
|
l=task.LoopingCall(data_que_send)
|
||||||
l.start(1)
|
l.start(1)
|
||||||
def data_que_send():
|
##def data_que_send():
|
||||||
#logger.info('Check SMS que')
|
## #logger.info('Check SMS que')
|
||||||
try:
|
## try:
|
||||||
#logger.info(UNIT_MAP)
|
## #logger.info(UNIT_MAP)
|
||||||
for packet_file in os.listdir('/tmp/.hblink_data_que_' + str(CONFIG['DATA_CONFIG']['APRS_LOGIN_CALL']).upper() + '/'):
|
## for packet_file in os.listdir('/tmp/.hblink_data_que_' + str(CONFIG['DATA_CONFIG']['APRS_LOGIN_CALL']).upper() + '/'):
|
||||||
logger.info('Sending SMS')
|
## logger.info('Sending SMS')
|
||||||
logger.info(os.listdir('/tmp/.hblink_data_que_' + str(CONFIG['DATA_CONFIG']['APRS_LOGIN_CALL']).upper() + '/'))
|
## logger.info(os.listdir('/tmp/.hblink_data_que_' + str(CONFIG['DATA_CONFIG']['APRS_LOGIN_CALL']).upper() + '/'))
|
||||||
snd_seq = ast.literal_eval(os.popen('cat /tmp/.hblink_data_que_' + str(CONFIG['DATA_CONFIG']['APRS_LOGIN_CALL']).upper() + '/' + packet_file).read())
|
## snd_seq = ast.literal_eval(os.popen('cat /tmp/.hblink_data_que_' + str(CONFIG['DATA_CONFIG']['APRS_LOGIN_CALL']).upper() + '/' + packet_file).read())
|
||||||
for data in snd_seq:
|
## for data in snd_seq:
|
||||||
# Get dest id
|
## # Get dest id
|
||||||
dst_id = bytes.fromhex(str(data[10:16])[2:-1])
|
## dst_id = bytes.fromhex(str(data[10:16])[2:-1])
|
||||||
call_type = hex2bits(data)[121:122]
|
## call_type = hex2bits(data)[121:122]
|
||||||
# Handle UNIT calls
|
## # Handle UNIT calls
|
||||||
if call_type[0] == True:
|
## if call_type[0] == True:
|
||||||
# If destination ID in map, route call only there
|
## # If destination ID in map, route call only there
|
||||||
if dst_id in UNIT_MAP:
|
## if dst_id in UNIT_MAP:
|
||||||
data_target = UNIT_MAP[dst_id][0]
|
## data_target = UNIT_MAP[dst_id][0]
|
||||||
reactor.callFromThread(systems[data_target].send_system,bytes.fromhex(re.sub("b'|'", '', str(data))))
|
## reactor.callFromThread(systems[data_target].send_system,bytes.fromhex(re.sub("b'|'", '', str(data))))
|
||||||
logger.info('Sending data to ' + str(data[10:16])[2:-1] + ' on system ' + data_target)
|
## logger.info('Sending data to ' + str(data[10:16])[2:-1] + ' on system ' + data_target)
|
||||||
# Flood all systems
|
## # Flood all systems
|
||||||
elif dst_id not in UNIT_MAP:
|
## elif dst_id not in UNIT_MAP:
|
||||||
for i in UNIT:
|
## for i in UNIT:
|
||||||
reactor.callFromThread(systems[i].send_system,bytes.fromhex(re.sub("b'|'", '', str(data))))
|
## reactor.callFromThread(systems[i].send_system,bytes.fromhex(re.sub("b'|'", '', str(data))))
|
||||||
logger.info('Sending data to ' + str(data[10:16])[2:-1] + ' on system ' + i)
|
## logger.info('Sending data to ' + str(data[10:16])[2:-1] + ' on system ' + i)
|
||||||
# Handle group calls
|
## # Handle group calls
|
||||||
elif call_type[0] == False:
|
## elif call_type[0] == False:
|
||||||
for i in BRIDGES.items():
|
## for i in BRIDGES.items():
|
||||||
for d in i[1]:
|
## for d in i[1]:
|
||||||
if dst_id == d['TGID']:
|
## if dst_id == d['TGID']:
|
||||||
data_target = d['SYSTEM']
|
## data_target = d['SYSTEM']
|
||||||
reactor.callFromThread(systems[data_target].send_system,bytes.fromhex(re.sub("b'|'", '', str(data))))
|
## reactor.callFromThread(systems[data_target].send_system,bytes.fromhex(re.sub("b'|'", '', str(data))))
|
||||||
logger.info('Sending data to ' + str(data[10:16])[2:-1] + ' on system ' + data_target)
|
## logger.info('Sending data to ' + str(data[10:16])[2:-1] + ' on system ' + data_target)
|
||||||
|
##
|
||||||
os.system('rm /tmp/.hblink_data_que_' + str(CONFIG['DATA_CONFIG']['APRS_LOGIN_CALL']).upper() + '/' + packet_file)
|
## os.system('rm /tmp/.hblink_data_que_' + str(CONFIG['DATA_CONFIG']['APRS_LOGIN_CALL']).upper() + '/' + packet_file)
|
||||||
|
##
|
||||||
|
## #routerHBP.send_peer('MASTER-2', bytes.fromhex(re.sub("b'|'", '', str(data))))
|
||||||
|
## ## os.system('rm /tmp/.hblink_data_que/' + packet_file)
|
||||||
|
## except Exception as e:
|
||||||
|
## logger.info(e)
|
||||||
|
|
||||||
#routerHBP.send_peer('MASTER-2', bytes.fromhex(re.sub("b'|'", '', str(data))))
|
def aprs_process(packet):
|
||||||
## os.system('rm /tmp/.hblink_data_que/' + packet_file)
|
try:
|
||||||
except Exception as e:
|
if 'addresse' in aprslib.parse(packet):
|
||||||
logger.info(e)
|
#print(aprslib.parse(packet))
|
||||||
|
recipient = re.sub('-.*','', aprslib.parse(packet)['addresse'])
|
||||||
|
recipient_ssid = re.sub('.*-','', aprslib.parse(packet)['addresse'])
|
||||||
|
if recipient == '':
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
|
||||||
|
for i in user_settings.items():
|
||||||
|
sms_id = i[0]
|
||||||
|
ssid = i[1][1]['ssid']
|
||||||
|
if i[1][1]['ssid'] == '':
|
||||||
|
ssid = user_ssid
|
||||||
|
if recipient in i[1][0]['call'] and i[1][5]['APRS'] == True and recipient_ssid in ssid:
|
||||||
|
mailbox_write(re.sub('-.*','', aprslib.parse(packet)['addresse']), aprslib.parse(packet)['from'], time(), aprslib.parse(packet)['message_text'], recipient)
|
||||||
|
send_sms(False, sms_id, 0000, 0000, 'unit', str('APRS / ' + str(aprslib.parse(packet)['from']) + ': ' + aprslib.parse(packet)['message_text']))
|
||||||
|
try:
|
||||||
|
if 'msgNo' in aprslib.parse(packet):
|
||||||
|
#sleep(1)
|
||||||
|
logger.info(str(aprslib.parse(packet)['addresse']) + '>APHBL3,TCPIP*:' + ':' + str(aprslib.parse(packet)['from'].ljust(9)) +':ack' + str(aprslib.parse(packet)['msgNo']))
|
||||||
|
aprs_send(str(aprslib.parse(packet)['addresse']) + '>APHBL3,TCPIP*:' + ':' + str(aprslib.parse(packet)['from'].ljust(9)) +':ack' + str(aprslib.parse(packet)['msgNo']))
|
||||||
|
logger.info('Send ACK')
|
||||||
|
except Exception as e:
|
||||||
|
logger.info(e)
|
||||||
|
except:
|
||||||
|
logger.info('aprs except')
|
||||||
|
|
||||||
# the APRS RX process
|
# the APRS RX process
|
||||||
def aprs_rx(aprs_rx_login, aprs_passcode, aprs_server, aprs_port, aprs_filter, user_ssid):
|
def aprs_rx(aprs_rx_login, aprs_passcode, aprs_server, aprs_port, aprs_filter, user_ssid):
|
||||||
@ -1061,6 +1090,11 @@ def aprs_rx(aprs_rx_login, aprs_passcode, aprs_server, aprs_port, aprs_filter, u
|
|||||||
AIS.consumer(aprs_process, raw=True, immortal=False)
|
AIS.consumer(aprs_process, raw=True, immortal=False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info(e)
|
logger.info(e)
|
||||||
|
|
||||||
|
def aprs_beacon_send():
|
||||||
|
beacon_packet = CONFIG['GPS_DATA']['APRS_LOGIN_CALL'] + '>APHBL3,TCPIP*:!' + CONFIG['GPS_DATA']['IGATE_LATITUDE'] + str(CONFIG['GPS_DATA']['IGATE_BEACON_ICON'][0]) + CONFIG['GPS_DATA']['IGATE_LONGITUDE'] + str(CONFIG['GPS_DATA']['IGATE_BEACON_ICON'][1]) + '/' + CONFIG['GPS_DATA']['IGATE_BEACON_COMMENT']
|
||||||
|
aprs_send(beacon_packet)
|
||||||
|
logger.info(beacon_packet)
|
||||||
|
|
||||||
##### DMR data function ####
|
##### DMR data function ####
|
||||||
def data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
|
def data_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
|
||||||
|
50
web/app.py
50
web/app.py
@ -501,7 +501,7 @@ def hbnet_web_service():
|
|||||||
id = db.Column(db.Integer(), primary_key=True)
|
id = db.Column(db.Integer(), primary_key=True)
|
||||||
author = db.Column(db.String(100), nullable=False, server_default='')
|
author = db.Column(db.String(100), nullable=False, server_default='')
|
||||||
content = db.Column(db.String(150), nullable=False, server_default='')
|
content = db.Column(db.String(150), nullable=False, server_default='')
|
||||||
query = db.Column(db.String(100), nullable=False, server_default='')
|
query_term = db.Column(db.String(100), nullable=False, server_default='', unique=False)
|
||||||
time = db.Column(db.DateTime())
|
time = db.Column(db.DateTime())
|
||||||
|
|
||||||
class Misc(db.Model):
|
class Misc(db.Model):
|
||||||
@ -2453,6 +2453,45 @@ TG #: <strong> ''' + str(tg_d.tg) + '''</strong>
|
|||||||
</tr>'''
|
</tr>'''
|
||||||
return render_template('bb.html', markup_content = Markup(content))
|
return render_template('bb.html', markup_content = Markup(content))
|
||||||
|
|
||||||
|
@app.route('/tp')
|
||||||
|
def all_tp():
|
||||||
|
tpl = TinyPage.query.order_by(TinyPage.time.desc()).all()
|
||||||
|
content = ''' '''
|
||||||
|
for i in tpl:
|
||||||
|
content = content + '''
|
||||||
|
<tr>
|
||||||
|
<td><strong>''' + i.query_term + '''</strong></td>
|
||||||
|
<td>''' + i.content + '''</td>
|
||||||
|
<td>''' + i.author + '''</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>'''
|
||||||
|
return render_template('tp_all.html', markup_content = Markup(content))
|
||||||
|
|
||||||
|
@app.route('/add_tp', methods=['POST', 'GET'])
|
||||||
|
## @app.route('/add_tp')
|
||||||
|
def new_tp():
|
||||||
|
u = current_user
|
||||||
|
print(u.username)
|
||||||
|
if request.args.get('add_page'):
|
||||||
|
tp_add(u.username, request.form.get('query'), request.form.get('content'))
|
||||||
|
content = '''<h3 style="text-align: center;">Saved Tiny Page.</h3>
|
||||||
|
<p style="text-align: center;">Redirecting in 1 seconds.</p>
|
||||||
|
<meta http-equiv="refresh" content="1; URL=''' + url + '''/tp" /> '''
|
||||||
|
|
||||||
|
else:
|
||||||
|
content = ''
|
||||||
|
## tpl = TinyPage.query.order_by(TinyPage.time.desc()).all()
|
||||||
|
## content = ''' '''
|
||||||
|
## for i in tpl:
|
||||||
|
## content = content + '''
|
||||||
|
## <tr>
|
||||||
|
## <td><strong>''' + i.query_term + '''</strong></td>
|
||||||
|
## <td>''' + i.content + '''</td>
|
||||||
|
## <td>''' + i.author + '''</td>
|
||||||
|
##
|
||||||
|
## </tr>'''
|
||||||
|
return render_template('tp_add.html', markup_content = Markup(content), url = url)
|
||||||
|
|
||||||
@app.route('/ss')
|
@app.route('/ss')
|
||||||
def get_all_ss():
|
def get_all_ss():
|
||||||
ss_all = Social.query.order_by(Social.time.desc()).all()
|
ss_all = Social.query.order_by(Social.time.desc()).all()
|
||||||
@ -2854,11 +2893,12 @@ Name: <strong>''' + p.name + '''</strong> - Port: <strong>''' + str(
|
|||||||
db.session.add(add_loc)
|
db.session.add(add_loc)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
def tp_add(_callsign, _bulletin, _dmr_id, _server, _system_name):
|
def tp_add(_author, _query_term, _content):
|
||||||
add_tp = BulletinBoard(
|
add_tp = TinyPage(
|
||||||
author = _author,
|
author = _author,
|
||||||
query = _query,
|
query_term = _query_term,
|
||||||
content = _content
|
content = _content,
|
||||||
|
time = datetime.datetime.utcnow(),
|
||||||
)
|
)
|
||||||
db.session.add(add_tp)
|
db.session.add(add_tp)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
{# Label on left, "New here? Register." on right #}
|
{# Label on left, "New here? Register." on right #}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-6">
|
<div class="col-xs-6">
|
||||||
<label for="{{ field.id }}" class="control-label">{{ field.label.text }}</label>
|
<label for="{{ field.id }}" class="control-label"><strong>{{ field.label.text }}</strong></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 text-right">
|
<div class="col-xs-6 text-right">
|
||||||
{% if user_manager.USER_ENABLE_REGISTER and not user_manager.USER_REQUIRE_INVITATION %}
|
{% if user_manager.USER_ENABLE_REGISTER and not user_manager.USER_REQUIRE_INVITATION %}
|
||||||
@ -43,7 +43,7 @@
|
|||||||
{# Label on left, "Forgot your Password?" on right #}
|
{# Label on left, "Forgot your Password?" on right #}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-6">
|
<div class="col-xs-6">
|
||||||
<label for="{{ field.id }}" class="control-label">{{ field.label.text }}</label>
|
<label for="{{ field.id }}" class="control-label"><strong>{{ field.label.text }}</strong></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 text-right">
|
<div class="col-xs-6 text-right">
|
||||||
{% if user_manager.USER_ENABLE_FORGOT_PASSWORD %}
|
{% if user_manager.USER_ENABLE_FORGOT_PASSWORD %}
|
||||||
|
@ -25,7 +25,7 @@ By registering, you acknowledge that you agree to the Terms of Use.
|
|||||||
{# Label on left, "Already registered? Sign in." on right #}
|
{# Label on left, "Already registered? Sign in." on right #}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-6">
|
<div class="col-xs-6">
|
||||||
<label for="{{ field.id }}" class="control-label">{{ field.label.text }}</label>
|
<label for="{{ field.id }}" class="control-label"><strong>{{ field.label.text }}</strong></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-6 text-right">
|
<div class="col-xs-6 text-right">
|
||||||
{% if user_manager.USER_ENABLE_REGISTER %}
|
{% if user_manager.USER_ENABLE_REGISTER %}
|
||||||
|
30
web/templates/tp_add.html
Normal file
30
web/templates/tp_add.html
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{% extends 'flask_user/_public_base.html' %}
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1 style="text-align: center;">Tiny Pages</h1>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
|
||||||
|
|
||||||
|
<form action="?add_page=true" method="post">
|
||||||
|
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<span class="input-group-text" id="basic-addon1"><strong>?</strong></span>
|
||||||
|
<input type="text" id="username" placeholder="Query" name="query" class="form-control" aria-label="Query" aria-describedby="basic-addon1">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-text">Content</span>
|
||||||
|
<textarea id="message" name="content" class="form-control" aria-label="Content"></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<p style="text-align: center;"><input class="btn btn-primary" type="submit" value="Add" /></form></p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p> </p>
|
||||||
|
{% endblock %}
|
32
web/templates/tp_all.html
Normal file
32
web/templates/tp_all.html
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{% extends 'flask_user/_public_base.html' %}
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1 style="text-align: center;">Tiny Pages</h1>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
{% if call_or_get(current_user.is_authenticated) %}
|
||||||
|
<button type="button" class="btn btn-primary">Add Tiny Page</button>
|
||||||
|
{% endif %}
|
||||||
|
<table data-toggle="table" data-pagination="true" data-search="true" >
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Query</th>
|
||||||
|
<th>Content</th>
|
||||||
|
<th>Author</th>
|
||||||
|
<th>Options</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
{{markup_content}}
|
||||||
|
|
||||||
|
</tbody></table>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p> </p>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user