From a91eb65273a1d419647a99d3ea4193f89e698e3d Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Tue, 2 Mar 2021 13:40:03 -0800 Subject: [PATCH] make mailbox file persistent --- bridge_gps_data.py | 14 +++++++------- gps_data.py | 14 +++++++------- scripts/dashboard/dashboard.py | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bridge_gps_data.py b/bridge_gps_data.py index f0518ef..ff8fef7 100755 --- a/bridge_gps_data.py +++ b/bridge_gps_data.py @@ -186,21 +186,21 @@ def dashboard_bb_write(call, dmr_id, time, bulletin): def mailbox_write(call, dmr_id, time, message, recipient): #try: - mail_file = ast.literal_eval(os.popen('cat /tmp/gps_data_user_mailbox.txt').read()) + mail_file = ast.literal_eval(os.popen('cat ./gps_data_user_mailbox.txt').read()) mail_file.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'message':message, 'recipient': recipient}) - with open("/tmp/gps_data_user_mailbox.txt", 'w') as mailbox_file: + with open("./gps_data_user_mailbox.txt", 'w') as mailbox_file: mailbox_file.write(str(mail_file[:100])) mailbox_file.close() logger.info('User mail saved.') def mailbox_delete(dmr_id): - mail_file = ast.literal_eval(os.popen('cat /tmp/gps_data_user_mailbox.txt').read()) + mail_file = ast.literal_eval(os.popen('cat ./gps_data_user_mailbox.txt').read()) call = str(get_alias((dmr_id), subscriber_ids)) new_data = [] for message in mail_file: if message['recipient'] != call: new_data.append(message) - with open("/tmp/gps_data_user_mailbox.txt", 'w') as mailbox_file: + with open("./gps_data_user_mailbox.txt", 'w') as mailbox_file: mailbox_file.write(str(new_data[:100])) mailbox_file.close() logger.info('Mailbox updated. Delete occurred.') @@ -1792,11 +1792,11 @@ if __name__ == '__main__': with open("/tmp/gps_data_user_bb.txt", 'w') as user_bb_file: user_bb_file.write("[]") user_bb_file.close() - if Path('/tmp/gps_data_user_mailbox.txt').is_file(): + if Path('./gps_data_user_mailbox.txt').is_file(): pass else: - Path('/tmp/gps_data_user_mailbox.txt').touch() - with open("/tmp/gps_data_user_mailbox.txt", 'w') as user_loc_file: + Path('./gps_data_user_mailbox.txt').touch() + with open("./gps_data_user_mailbox.txt", 'w') as user_loc_file: user_loc_file.write("[]") user_loc_file.close() diff --git a/gps_data.py b/gps_data.py index 165c8a2..7068327 100644 --- a/gps_data.py +++ b/gps_data.py @@ -179,21 +179,21 @@ def dashboard_bb_write(call, dmr_id, time, bulletin): def mailbox_write(call, dmr_id, time, message, recipient): #try: - mail_file = ast.literal_eval(os.popen('cat /tmp/gps_data_user_mailbox.txt').read()) + mail_file = ast.literal_eval(os.popen('cat ./gps_data_user_mailbox.txt').read()) mail_file.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'message':message, 'recipient': recipient}) - with open("/tmp/gps_data_user_mailbox.txt", 'w') as mailbox_file: + with open("./gps_data_user_mailbox.txt", 'w') as mailbox_file: mailbox_file.write(str(mail_file[:100])) mailbox_file.close() logger.info('User mail saved.') def mailbox_delete(dmr_id): - mail_file = ast.literal_eval(os.popen('cat /tmp/gps_data_user_mailbox.txt').read()) + mail_file = ast.literal_eval(os.popen('cat ./gps_data_user_mailbox.txt').read()) call = str(get_alias((dmr_id), subscriber_ids)) new_data = [] for message in mail_file: if message['recipient'] != call: new_data.append(message) - with open("/tmp/gps_data_user_mailbox.txt", 'w') as mailbox_file: + with open("./gps_data_user_mailbox.txt", 'w') as mailbox_file: mailbox_file.write(str(new_data[:100])) mailbox_file.close() logger.info('Mailbox updated. Delete occurred.') @@ -694,11 +694,11 @@ if __name__ == '__main__': with open("/tmp/gps_data_user_bb.txt", 'w') as user_bb_file: user_bb_file.write("[]") user_bb_file.close() - if Path('/tmp/gps_data_user_mailbox.txt').is_file(): + if Path('./gps_data_user_mailbox.txt').is_file(): pass else: - Path('/tmp/gps_data_user_mailbox.txt').touch() - with open("/tmp/gps_data_user_mailbox.txt", 'w') as user_loc_file: + Path('./gps_data_user_mailbox.txt').touch() + with open("./gps_data_user_mailbox.txt", 'w') as user_loc_file: user_loc_file.write("[]") user_loc_file.close() # CLI argument parser - handles picking up the config file from the command line, and sending a "help" message diff --git a/scripts/dashboard/dashboard.py b/scripts/dashboard/dashboard.py index 2bdaca4..67acad2 100644 --- a/scripts/dashboard/dashboard.py +++ b/scripts/dashboard/dashboard.py @@ -471,7 +471,7 @@ def mailbox(): """ else: - mailbox_file = ast.literal_eval(os.popen('cat /tmp/gps_data_user_mailbox.txt').read()) + mailbox_file = ast.literal_eval(os.popen('cat ../../gps_data_user_mailbox.txt').read()) mail_content = '

Messages for: ' + recipient.upper() + '''

\n

\n

Mailbox RSS Feed for ''' + recipient.upper() + '''

@@ -537,7 +537,7 @@ def bb_rss(): @app.route('/mailbox_rss') def mail_rss(): - mailbox_file = ast.literal_eval(os.popen('cat /tmp/gps_data_user_mailbox.txt').read()) + mailbox_file = ast.literal_eval(os.popen('cat ../../gps_data_user_mailbox.txt').read()) post_data = '' recipient = request.args.get('recipient').upper() rss_header = """