refs #2281 fix logout on windows

unificar-endpoints
Natalia Serrano 2025-06-23 12:27:45 +02:00
parent 22f7ce0bb9
commit bb856e5b63
8 changed files with 33 additions and 12 deletions

View File

@ -6,6 +6,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [6.0.0] - 2025-06-19
### Changed
- Changed the names of some endpoints for consistency between oglive and OS
- Changed label in the windows installer
## [5.9.0] - 2025-06-16
### Added

View File

@ -1,3 +1,10 @@
ogagent (6.0.0-1) stable; urgency=medium
* Unify API methods for poweroff, reboot and run script
* Change label in the windows installer
-- OpenGnsys developers <info@opengnsys.es> Fri, 20 Jun 2025 10:03:15 +0200
ogagent (5.9.0-1) stable; urgency=medium
* Add changes for oggit

View File

@ -1 +1 @@
5.9.0
6.0.0

View File

@ -209,7 +209,7 @@ class REST(object):
r.raise_for_status()
ct = r.headers['Content-Type']
if 'application/json' != ct:
if len(ct) < 16 or 'application/json' != ct[0:16]:
raise Exception (f'response content-type is not "application/json" but "{ct}"')
r = json.loads(r.content) # Using instead of r.json() to make compatible with old requests lib versions
except requests.exceptions.RequestException as e:

View File

@ -165,6 +165,9 @@ class ClientProcessor(threading.Thread):
logger.debug('Got invalid message from request: {}, state: {}'.format(buf, state))
except socket.error as e:
# If no data is present, no problem at all, pass to check messages
if '[WinError 10054]' in str(e):
## windows: client disconnected
self.running = False
pass
except Exception as e:
tb = traceback.format_exc()

View File

@ -71,6 +71,13 @@ class OGAgentSvc(Daemon, CommonService):
# example
try:
while self.isAlive:
client_died=False
if os.path.exists ('/tmp/ogagentuser_died'):
os.unlink ('/tmp/ogagentuser_died')
client_died=True
if client_died:
self.notifyLogout (b'')
# In milliseconds, will break
self.doWait(1000)
except (KeyboardInterrupt, SystemExit) as e:

View File

@ -198,16 +198,6 @@ class CommonService(object):
Invoked to wait a bit
CAN be OVERRIDDEN
"""
client_died=False
if os.path.exists ('/windows/temp/ogagentuser_died'):
os.unlink ('/windows/temp/ogagentuser_died')
client_died=True
elif os.path.exists ('/tmp/ogagentuser_died'):
os.unlink ('/tmp/ogagentuser_died')
client_died=True
if client_died:
self.notifyLogout (b'')
time.sleep(float(miliseconds) / 1000)
def notifyStop(self):

View File

@ -106,6 +106,13 @@ class OGAgentSvc(win32serviceutil.ServiceFramework, CommonService):
# *********************
try:
while self.isAlive:
client_died=False
if os.path.exists ('/windows/temp/ogagentuser_died'):
os.unlink ('/windows/temp/ogagentuser_died')
client_died=True
if client_died:
self.notifyLogout (b'')
# Pumps & processes any waiting messages
pythoncom.PumpWaitingMessages()
win32event.WaitForSingleObject(self.hWaitStop, 1000)