add missing file

This commit is contained in:
KF7EEL 2022-02-21 19:21:52 -08:00
parent 52bd918a23
commit 07ba271682
1 changed files with 128 additions and 127 deletions

View File

@ -606,142 +606,143 @@ def dashboard_sms_write(snd_call, rcv_call, rcv_dmr_id, snd_dmr_id, sms, time, s
def mailbox_write(call, dmr_id, time, message, recipient): def mailbox_write(call, dmr_id, time, message, recipient):
if LOCAL_CONFIG['DATA_CONFIG']['USE_DASHBOARD'] == True: ## if LOCAL_CONFIG['DATA_CONFIG']['USE_DASHBOARD'] == True:
#try: ## #try:
print(call) ## print(call)
print() ## print()
print() ## print()
print(recipient) ## print(recipient)
if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True: if CONFIG['WEB_SERVICE']['REMOTE_CONFIG_ENABLED'] == True:
send_mb(CONFIG, call, recipient, message, 0, 0, 'APRS-IS') send_mb(CONFIG, call, recipient, message, 0, 0, 'APRS-IS')
else: else:
mail_file = ast.literal_eval(os.popen('cat ' + the_mailbox_file).read()) ## mail_file = ast.literal_eval(os.popen('cat ' + the_mailbox_file).read())
mail_file.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'message':message, 'recipient': recipient}) ## mail_file.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'message':message, 'recipient': recipient})
with open(the_mailbox_file, 'w') as mailbox_file: ## with open(the_mailbox_file, 'w') as mailbox_file:
mailbox_file.write(str(mail_file[:100])) ## mailbox_file.write(str(mail_file[:100]))
mailbox_file.close() ## mailbox_file.close()
logger.info('User mail saved.') ## logger.info('User mail saved.')
else: ## else:
pass ## pass
def mailbox_delete(dmr_id): ##def mailbox_delete(dmr_id):
if LOCAL_CONFIG['DATA_CONFIG']['USE_DASHBOARD'] == True: ## if LOCAL_CONFIG['DATA_CONFIG']['USE_DASHBOARD'] == True:
mail_file = ast.literal_eval(os.popen('cat ' + the_mailbox_file).read()) ## mail_file = ast.literal_eval(os.popen('cat ' + the_mailbox_file).read())
call = str(get_alias((dmr_id), subscriber_ids)) ## call = str(get_alias((dmr_id), subscriber_ids))
new_data = [] ## new_data = []
for message in mail_file: ## for message in mail_file:
if message['recipient'] != call: ## if message['recipient'] != call:
new_data.append(message) ## new_data.append(message)
with open(the_mailbox_file, 'w') as mailbox_file: ## with open(the_mailbox_file, 'w') as mailbox_file:
mailbox_file.write(str(new_data[:100])) ## mailbox_file.write(str(new_data[:100]))
mailbox_file.close() ## mailbox_file.close()
logger.info('Mailbox updated. Delete occurred.') ## logger.info('Mailbox updated. Delete occurred.')
else: ## else:
pass ## pass
def sos_write(dmr_id, time, message): ##def sos_write(dmr_id, time, message):
if LOCAL_CONFIG['DATA_CONFIG']['USE_DASHBOARD'] == True: ## if LOCAL_CONFIG['DATA_CONFIG']['USE_DASHBOARD'] == True:
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read()) ## user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
print(user_settings) ## print(user_settings)
try: ## try:
if user_settings[dmr_id][1]['ssid'] == '': ## if user_settings[dmr_id][1]['ssid'] == '':
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_ssid ## sos_call = user_settings[dmr_id][0]['call'] + '-' + user_ssid
else: ## else:
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_settings[dmr_id][1]['ssid'] ## sos_call = user_settings[dmr_id][0]['call'] + '-' + user_settings[dmr_id][1]['ssid']
except: ## except:
sos_call = str(get_alias((dmr_id), subscriber_ids)) ## sos_call = str(get_alias((dmr_id), subscriber_ids))
sos_info = {'call': sos_call, 'dmr_id': dmr_id, 'time': time, 'message':message} ## sos_info = {'call': sos_call, 'dmr_id': dmr_id, 'time': time, 'message':message}
with open(emergency_sos_file, 'w') as sos_file: ## with open(emergency_sos_file, 'w') as sos_file:
sos_file.write(str(sos_info)) ## sos_file.write(str(sos_info))
sos_file.close() ## sos_file.close()
logger.info('Saved SOS.') ## logger.info('Saved SOS.')
else: ## else:
pass ## pass
def send_app_request(url, message, source_id):
#url = url + '/app'
#Load current AUTH token list
auth_file = ast.literal_eval(os.popen('cat ' + auth_token_file).read())
the_token = str(hashlib.md5(str(time()).encode('utf-8')).hexdigest())
new_auth_file = auth_file
new_auth_file.append(the_token)
# Write new list to file
with open(auth_token_file, 'w') as auth_token:
auth_token.write(str(auth_file))
auth_token.close()
app_request = {
'mode':'app',
'system_shortcut':CONFIG['DATA_CONFIG']['MY_SERVER_SHORTCUT'],
'server_name':CONFIG['DATA_CONFIG']['SERVER_NAME'],
'response_url':CONFIG['DATA_CONFIG']['DASHBOARD_URL'] + '/api',
'auth_token':the_token,
'data':{
'source_id':source_id,
'slot':0,
'msg_type':'unit',
'msg_format':'motorola',
'message':message
}
}
json_object = json.dumps(app_request, indent = 4)
print(json_object)
requests.post(url, data=json_object, headers={'Content-Type': 'application/json'})
def send_msg_xfer(url, user, password, message, source_id, dest_id): ##def send_app_request(url, message, source_id):
url = url + '/api/msg_xfer' ## #url = url + '/app'
msg_xfer = { ## #Load current AUTH token list
'mode':'msg_xfer', ## auth_file = ast.literal_eval(os.popen('cat ' + auth_token_file).read())
'system_shortcut':CONFIG['DATA_CONFIG']['MY_SERVER_SHORTCUT'], ## the_token = str(hashlib.md5(str(time()).encode('utf-8')).hexdigest())
'response_url':CONFIG['DATA_CONFIG']['DASHBOARD_URL'] + '/api', ## new_auth_file = auth_file
'auth_type':'private', ## new_auth_file.append(the_token)
'credentials': { ## # Write new list to file
'user':user, ## with open(auth_token_file, 'w') as auth_token:
'password':password, ## auth_token.write(str(auth_file))
}, ## auth_token.close()
'data':{ ## app_request = {
1:{'source_id':source_id, ## 'mode':'app',
'destination_id':dest_id, ## 'system_shortcut':CONFIG['DATA_CONFIG']['MY_SERVER_SHORTCUT'],
'slot':0, ## 'server_name':CONFIG['DATA_CONFIG']['SERVER_NAME'],
'msg_type':'unit', ## 'response_url':CONFIG['DATA_CONFIG']['DASHBOARD_URL'] + '/api',
'msg_format':'motorola', ## 'auth_token':the_token,
'message':message ## 'data':{
} ## 'source_id':source_id,
} ## 'slot':0,
} ## 'msg_type':'unit',
json_object = json.dumps(msg_xfer, indent = 4) ## 'msg_format':'motorola',
requests.post(url, data=json_object, headers={'Content-Type': 'application/json'}) ## 'message':message
## }
## }
## json_object = json.dumps(app_request, indent = 4)
## print(json_object)
## requests.post(url, data=json_object, headers={'Content-Type': 'application/json'})
##
##
##def send_msg_xfer(url, user, password, message, source_id, dest_id):
## url = url + '/api/msg_xfer'
## msg_xfer = {
## 'mode':'msg_xfer',
## 'system_shortcut':CONFIG['DATA_CONFIG']['MY_SERVER_SHORTCUT'],
## 'response_url':CONFIG['DATA_CONFIG']['DASHBOARD_URL'] + '/api',
## 'auth_type':'private',
## 'credentials': {
## 'user':user,
## 'password':password,
## },
## 'data':{
## 1:{'source_id':source_id,
## 'destination_id':dest_id,
## 'slot':0,
## 'msg_type':'unit',
## 'msg_format':'motorola',
## 'message':message
## }
## }
## }
## json_object = json.dumps(msg_xfer, indent = 4)
## requests.post(url, data=json_object, headers={'Content-Type': 'application/json'})
# Send email via SMTP function ### Send email via SMTP function
def send_email(to_email, email_subject, email_message): ##def send_email(to_email, email_subject, email_message):
global smtp_server ## global smtp_server
sender_address = email_sender ## sender_address = email_sender
account_password = email_password ## account_password = email_password
smtp_server = smtplib.SMTP_SSL(smtp_server, int(smtp_port)) ## smtp_server = smtplib.SMTP_SSL(smtp_server, int(smtp_port))
smtp_server.login(sender_address, account_password) ## smtp_server.login(sender_address, account_password)
message = "From: " + aprs_callsign + " D-APRS Gateway\nTo: " + to_email + "\nContent-type: text/html\nSubject: " + email_subject + "\n\n" + '<strong>' + email_subject + '</strong><p>&nbsp;</p><h3>' + email_message + '</h3><p>&nbsp;</p><p>This message was sent to you from a D-APRS gateway operated by <strong>' + aprs_callsign + '</strong>. Do not reply as this gateway is only one way at this time.</p>' ## message = "From: " + aprs_callsign + " D-APRS Gateway\nTo: " + to_email + "\nContent-type: text/html\nSubject: " + email_subject + "\n\n" + '<strong>' + email_subject + '</strong><p>&nbsp;</p><h3>' + email_message + '</h3><p>&nbsp;</p><p>This message was sent to you from a D-APRS gateway operated by <strong>' + aprs_callsign + '</strong>. Do not reply as this gateway is only one way at this time.</p>'
smtp_server.sendmail(sender_address, to_email, message) ## smtp_server.sendmail(sender_address, to_email, message)
smtp_server.close() ## smtp_server.close()
def generate_apps(): ##def generate_apps():
global access_systems ## global access_systems
#local_apps = ast.literal_eval(os.popen('cat ' + access_systems_file).read()) ## #local_apps = ast.literal_eval(os.popen('cat ' + access_systems_file).read())
public_systems_file = requests.get(CONFIG['DATA_CONFIG']['PUBLIC_APPS_LIST']) ## public_systems_file = requests.get(CONFIG['DATA_CONFIG']['PUBLIC_APPS_LIST'])
public_apps = ast.literal_eval(public_systems_file.text) ## public_apps = ast.literal_eval(public_systems_file.text)
access_systems = {} ## access_systems = {}
#combined = public_apps.items() + local_acess_systems.items() ## #combined = public_apps.items() + local_acess_systems.items()
if CONFIG['DATA_CONFIG']['USE_PUBLIC_APPS'] == True: ## if CONFIG['DATA_CONFIG']['USE_PUBLIC_APPS'] == True:
for i in public_apps.items(): ## for i in public_apps.items():
key = str(i[0]) ## key = str(i[0])
access_systems[key] = i[1] ## access_systems[key] = i[1]
for i in local_apps.items(): ## for i in local_apps.items():
key = str(i[0]) ## key = str(i[0])
access_systems[key] = i[1] ## access_systems[key] = i[1]
print(access_systems) ## print(access_systems)
##
return access_systems ## return access_systems
# Thanks for this forum post for this - https://stackoverflow.com/questions/2579535/convert-dd-decimal-degrees-to-dms-degrees-minutes-seconds-in-python # Thanks for this forum post for this - https://stackoverflow.com/questions/2579535/convert-dd-decimal-degrees-to-dms-degrees-minutes-seconds-in-python
@ -888,8 +889,8 @@ def process_sms(_rf_src, sms, call_type, system_name):
## message = re.sub('^@|.* M-|','',sms) ## message = re.sub('^@|.* M-|','',sms)
## recipient = re.sub('@| M-.*','',sms) ## recipient = re.sub('@| M-.*','',sms)
## mailbox_write(get_alias(int_id(_rf_src), subscriber_ids), int_id(_rf_src), time(), message, str(recipient).upper()) ## mailbox_write(get_alias(int_id(_rf_src), subscriber_ids), int_id(_rf_src), time(), message, str(recipient).upper())
elif '*REM MAIL' == sms: ## elif '*REM MAIL' == sms:
mailbox_delete(_rf_src) ## mailbox_delete(_rf_src)
elif '*MH' in parse_sms[0]: elif '*MH' in parse_sms[0]:
print(parse_sms) print(parse_sms)