Fixed deadline & idle check

This commit is contained in:
Adolfo Gómez 2019-12-18 08:36:31 +01:00
parent 33d2dbbc52
commit 9150e71840
2 changed files with 6 additions and 8 deletions

View File

@ -47,7 +47,7 @@ if __name__ == "__main__":
logger.info('Started UDS Client Actor') logger.info('Started UDS Client Actor')
# QApplication.setQuitOnLastWindowClosed(False) UDSClientQApp.setQuitOnLastWindowClosed(False)
qApp = UDSClientQApp(sys.argv) qApp = UDSClientQApp(sys.argv)

View File

@ -141,12 +141,12 @@ class UDSActorClient(threading.Thread): # pylint: disable=too-many-instance-att
idleTime = platform.operations.getIdleDuration() idleTime = platform.operations.getIdleDuration()
remainingTime = self._loginInfo.max_idle - idleTime remainingTime = self._loginInfo.max_idle - idleTime
logger.debug('Idle: %s Remaining: %s', idleTime, remainingTime)
if remainingTime > 120: # Reset show Warning dialog if we have more than 5 minutes left if remainingTime > 120: # Reset show Warning dialog if we have more than 5 minutes left
self._notified = False self._notified = False
return return
logger.debug('User has been idle for: {}'.format(idleTime))
if not self._notified and remainingTime < 120: # With two minutes, show a warning message if not self._notified and remainingTime < 120: # With two minutes, show a warning message
self._notified = True self._notified = True
self._showMessage('You have been idle for too long. The session will end if you don\'t resume operations.') self._showMessage('You have been idle for too long. The session will end if you don\'t resume operations.')
@ -167,19 +167,17 @@ class UDSActorClient(threading.Thread): # pylint: disable=too-many-instance-att
try: try:
# Notify loging and mark it # Notify loging and mark it
if platform.name != 'win32': # On win32, SENS will send login/logouts self._loginInfo = self.api.login(platform.operations.getCurrentUser())
self.api.login(platform.operations.getCurrentUser())
while self._running: while self._running:
time.sleep(1.1) # Sleeps between loop iterations time.sleep(1.3) # Sleeps between loop iterations
# Check Idle & dead line # Check Idle & dead line
self.checkIdle() self.checkIdle()
self.checkDeadLine() self.checkDeadLine()
self._loginInfo = None self._loginInfo = None
if platform.name != 'win32': # On win32, SENS will send login/logouts self.api.logout(platform.operations.getCurrentUser())
self.api.logout(platform.operations.getCurrentUser())
except Exception as e: except Exception as e:
logger.error('Error on client loop: %s', e) logger.error('Error on client loop: %s', e)