mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
Merge branch 'develop' into dependabot/npm_and_yarn/gui/develop/vite-plugin-electron-0.28.2
This commit is contained in:
commit
d95bea09a8
4 changed files with 24 additions and 19 deletions
|
@ -182,7 +182,6 @@ class ARQSessionISS(arq_session.ARQSession):
|
||||||
self.states.setARQ(False)
|
self.states.setARQ(False)
|
||||||
|
|
||||||
self.arq_data_type_handler.failed(self.type_byte, self.data)
|
self.arq_data_type_handler.failed(self.type_byte, self.data)
|
||||||
|
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
def abort_transmission(self, irs_frame=None):
|
def abort_transmission(self, irs_frame=None):
|
||||||
|
|
|
@ -171,21 +171,27 @@ class DatabaseManagerMessages(DatabaseManager):
|
||||||
finally:
|
finally:
|
||||||
session.remove()
|
session.remove()
|
||||||
|
|
||||||
def increment_message_attempts(self, message_id):
|
def increment_message_attempts(self, message_id, session=None):
|
||||||
session = self.get_thread_scoped_session()
|
own_session = False
|
||||||
|
if not session:
|
||||||
|
session = self.get_thread_scoped_session()
|
||||||
|
own_session = True
|
||||||
try:
|
try:
|
||||||
message = session.query(P2PMessage).filter_by(id=message_id).first()
|
message = session.query(P2PMessage).filter_by(id=message_id).first()
|
||||||
if message:
|
if message:
|
||||||
message.attempt += 1
|
message.attempt += 1
|
||||||
session.commit()
|
if own_session:
|
||||||
|
session.commit()
|
||||||
self.log(f"Incremented attempt count for message {message_id}")
|
self.log(f"Incremented attempt count for message {message_id}")
|
||||||
else:
|
else:
|
||||||
self.log(f"Message with ID {message_id} not found")
|
self.log(f"Message with ID {message_id} not found")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
session.rollback()
|
if own_session:
|
||||||
|
session.rollback()
|
||||||
self.log(f"An error occurred while incrementing attempts for message {message_id}: {e}")
|
self.log(f"An error occurred while incrementing attempts for message {message_id}: {e}")
|
||||||
finally:
|
finally:
|
||||||
session.remove()
|
if own_session:
|
||||||
|
session.remove()
|
||||||
|
|
||||||
def mark_message_as_read(self, message_id):
|
def mark_message_as_read(self, message_id):
|
||||||
session = self.get_thread_scoped_session()
|
session = self.get_thread_scoped_session()
|
||||||
|
@ -217,23 +223,21 @@ class DatabaseManagerMessages(DatabaseManager):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Query for messages with the specified callsign, 'failed' status, and fewer than 10 attempts
|
# Query for messages with the specified callsign, 'failed' status, and fewer than 10 attempts
|
||||||
messages = session.query(P2PMessage) \
|
message = session.query(P2PMessage) \
|
||||||
.filter(P2PMessage.origin_callsign == callsign) \
|
.filter(P2PMessage.destination_callsign == callsign) \
|
||||||
.filter(P2PMessage.status_id == failed_status.id) \
|
.filter(P2PMessage.status_id == failed_status.id) \
|
||||||
.filter(P2PMessage.attempt < 10) \
|
.filter(P2PMessage.attempt < 10) \
|
||||||
.all()
|
.first()
|
||||||
|
|
||||||
if messages:
|
if message:
|
||||||
# Update each message's status to 'queued'
|
# Increment attempt count using the existing function
|
||||||
for message in messages:
|
self.increment_message_attempts(message.id, session)
|
||||||
# Increment attempt count using the existing function
|
|
||||||
self.increment_message_attempts(message.id)
|
|
||||||
|
|
||||||
message.status_id = queued_status.id
|
message.status_id = queued_status.id
|
||||||
self.log(f"Set message {message.id} to queued and incremented attempt")
|
self.log(f"Set message {message.id} to queued and incremented attempt")
|
||||||
|
|
||||||
session.commit()
|
session.commit()
|
||||||
return {'status': 'success', 'message': f'{len(messages)} message(s) set to queued'}
|
return {'status': 'success', 'message': f'{len(message)} message(s) set to queued'}
|
||||||
else:
|
else:
|
||||||
return {'status': 'failure', 'message': 'No eligible messages found'}
|
return {'status': 'failure', 'message': 'No eligible messages found'}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -103,7 +103,7 @@ class TestARQSession(unittest.TestCase):
|
||||||
|
|
||||||
def waitForSession(self, q, outbound = False):
|
def waitForSession(self, q, outbound = False):
|
||||||
key = 'arq-transfer-outbound' if outbound else 'arq-transfer-inbound'
|
key = 'arq-transfer-outbound' if outbound else 'arq-transfer-inbound'
|
||||||
while True:
|
while True and self.channels_running:
|
||||||
ev = q.get()
|
ev = q.get()
|
||||||
if key in ev and ('success' in ev[key] or 'ABORTED' in ev[key]):
|
if key in ev and ('success' in ev[key] or 'ABORTED' in ev[key]):
|
||||||
self.logger.info(f"[{threading.current_thread().name}] {key} session ended.")
|
self.logger.info(f"[{threading.current_thread().name}] {key} session ended.")
|
||||||
|
@ -125,6 +125,7 @@ class TestARQSession(unittest.TestCase):
|
||||||
|
|
||||||
def waitAndCloseChannels(self):
|
def waitAndCloseChannels(self):
|
||||||
self.waitForSession(self.iss_event_queue, True)
|
self.waitForSession(self.iss_event_queue, True)
|
||||||
|
self.channels_running = False
|
||||||
self.waitForSession(self.irs_event_queue, False)
|
self.waitForSession(self.irs_event_queue, False)
|
||||||
self.channels_running = False
|
self.channels_running = False
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ class TestMessageProtocol(unittest.TestCase):
|
||||||
|
|
||||||
def waitForSession(self, q, outbound=False):
|
def waitForSession(self, q, outbound=False):
|
||||||
key = 'arq-transfer-outbound' if outbound else 'arq-transfer-inbound'
|
key = 'arq-transfer-outbound' if outbound else 'arq-transfer-inbound'
|
||||||
while True:
|
while True and self.channels_running:
|
||||||
ev = q.get()
|
ev = q.get()
|
||||||
if key in ev and ('success' in ev[key] or 'ABORTED' in ev[key]):
|
if key in ev and ('success' in ev[key] or 'ABORTED' in ev[key]):
|
||||||
self.logger.info(f"[{threading.current_thread().name}] {key} session ended.")
|
self.logger.info(f"[{threading.current_thread().name}] {key} session ended.")
|
||||||
|
@ -130,6 +130,7 @@ class TestMessageProtocol(unittest.TestCase):
|
||||||
|
|
||||||
def waitAndCloseChannels(self):
|
def waitAndCloseChannels(self):
|
||||||
self.waitForSession(self.iss_event_queue, True)
|
self.waitForSession(self.iss_event_queue, True)
|
||||||
|
self.channels_running = False
|
||||||
self.waitForSession(self.irs_event_queue, False)
|
self.waitForSession(self.irs_event_queue, False)
|
||||||
self.channels_running = False
|
self.channels_running = False
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue