From 0db7dbce9f04e66a2666a5f15290011f3702cbd6 Mon Sep 17 00:00:00 2001 From: jmbardallo Date: Thu, 9 Jul 2026 11:56:53 +0200 Subject: [PATCH] refactor(deps): remove obsolete dependencies and support modern Ubuntu --- linux/debian/changelog | 7 +++++++ linux/debian/control | 4 ++-- src/opengnsys/__init__.py | 12 +----------- src/opengnsys/httpserver.py | 7 +++---- src/opengnsys/linux/operations.py | 24 ++++-------------------- src/opengnsys/macos/operations.py | 16 ---------------- src/opengnsys/utils.py | 9 ++++----- src/requirements.txt | 2 +- 8 files changed, 22 insertions(+), 59 deletions(-) diff --git a/linux/debian/changelog b/linux/debian/changelog index 7a14615..9b6dea0 100644 --- a/linux/debian/changelog +++ b/linux/debian/changelog @@ -1,3 +1,10 @@ +ogagent (8.5.5-1) stable; urgency=medium + + * Remove obsolete dependencies (six, prctl, libxss1) to support modern Ubuntu releases (like 26.04) + * Update policykit-1 to polkitd + + -- OpenGnsys developers Thu, 09 Jul 2026 12:00:00 +0200 + ogagent (8.5.4-1) stable; urgency=medium * Fix network detection race condition on slow-booting machines: activation diff --git a/linux/debian/control b/linux/debian/control index c8d9e6e..7194250 100644 --- a/linux/debian/control +++ b/linux/debian/control @@ -11,7 +11,7 @@ Section: admin Priority: optional Architecture: all Depends: - policykit-1 (>= 0.100), python3 (>=3.4) | python (>= 3.4), python3-pyqt6, python3-requests, - python3-six, python3-prctl, python3-distro, libxss1, zenity, ${misc:Depends} + polkitd | policykit-1 (>= 0.100), python3 (>=3.4), python3-pyqt6, python3-requests, + python3-distro, zenity, ${misc:Depends} Description: OpenGnsys Agent for Operating Systems This package provides the required components to allow this machine to work on an environment managed by OpenGnsys. diff --git a/src/opengnsys/__init__.py b/src/opengnsys/__init__.py index cf7a335..7f99fe5 100644 --- a/src/opengnsys/__init__.py +++ b/src/opengnsys/__init__.py @@ -31,9 +31,6 @@ """ -# On centos, old six release does not includes byte2int, nor six.PY2 -import six - from . import modules from .RESTApi import REST, RESTError @@ -46,11 +43,4 @@ __author__ = 'Adolfo Gómez' __license__ = "BSD 3-clause" __copyright__ = "Copyright VirtualCable S.L.U." -if not hasattr(six, 'byte2int'): - if six.PY3: - import operator - six.byte2int = operator.itemgetter(0) - else: - def _byte2int(bs): - return ord(bs[0]) - six.byte2int = _byte2int + diff --git a/src/opengnsys/httpserver.py b/src/opengnsys/httpserver.py index 5879618..6dc4fe9 100644 --- a/src/opengnsys/httpserver.py +++ b/src/opengnsys/httpserver.py @@ -34,10 +34,9 @@ import os import json import ssl import threading -from six.moves.socketserver import ThreadingMixIn # @UnresolvedImport -from six.moves.BaseHTTPServer import BaseHTTPRequestHandler # @UnresolvedImport -from six.moves.BaseHTTPServer import HTTPServer # @UnresolvedImport -from six.moves.urllib.parse import unquote # @UnresolvedImport +from socketserver import ThreadingMixIn +from http.server import BaseHTTPRequestHandler, HTTPServer +from urllib.parse import unquote from .utils import exceptionToMessage from .certs import createSelfSignedCert diff --git a/src/opengnsys/linux/operations.py b/src/opengnsys/linux/operations.py index 9d2d928..5af98ee 100644 --- a/src/opengnsys/linux/operations.py +++ b/src/opengnsys/linux/operations.py @@ -41,7 +41,6 @@ import ctypes.util import subprocess import struct import array -import six import distro from opengnsys import utils @@ -53,12 +52,12 @@ def _getMacAddr(ifname): ''' if isinstance(ifname, list): return dict([(name, _getMacAddr(name)) for name in ifname]) - if isinstance(ifname, six.text_type): + if isinstance(ifname, str): ifname = ifname.encode('utf-8') # If unicode, convert to bytes (or str in python 2.7) try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) info = bytearray(fcntl.ioctl(s.fileno(), 0x8927, struct.pack(str('256s'), ifname[:15]))) - return six.text_type(''.join(['%02x:' % char for char in info[18:24]])[:-1]) + return str(''.join(['%02x:' % char for char in info[18:24]])[:-1]) except Exception: return None @@ -70,11 +69,11 @@ def _getIpAddr(ifname): ''' if isinstance(ifname, list): return dict([(name, _getIpAddr(name)) for name in ifname]) - if isinstance(ifname, six.text_type): + if isinstance(ifname, str): ifname = ifname.encode('utf-8') # If unicode, convert to bytes (or str in python 2.7) try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - return six.text_type(socket.inet_ntoa(fcntl.ioctl( + return str(socket.inet_ntoa(fcntl.ioctl( s.fileno(), 0x8915, # SIOCGIFADDR struct.pack(str('256s'), ifname[:15]) @@ -138,11 +137,6 @@ def reboot(flags=0): ''' Simple reboot using os command ''' - # Workaround for dummy thread - if six.PY3 is False: - import threading - threading._DummyThread._Thread__stop = lambda x: 42 - # Check for OpenGnsys Client or GNU/Linux distribution. if os.path.exists('/scripts/oginit'): subprocess.call('source /opt/opengnsys/etc/preinit/loadenviron.sh; /opt/opengnsys/scripts/reboot', shell=True) @@ -154,11 +148,6 @@ def poweroff(flags=0): ''' Simple poweroff using os command ''' - # Workaround for dummy thread - if six.PY3 is False: - import threading - threading._DummyThread._Thread__stop = lambda x: 42 - # Check for OpenGnsys Client or GNU/Linux distribution. if os.path.exists('/scripts/oginit'): subprocess.call('source /opt/opengnsys/etc/preinit/loadenviron.sh; /opt/opengnsys/scripts/poweroff', shell=True) @@ -171,11 +160,6 @@ def logoff(): Kills all curent user processes, which must send a logogof caveat: If the user has other sessions, will also disconnect from them ''' - # Workaround for dummy thread - if six.PY3 is False: - import threading - threading._DummyThread._Thread__stop = lambda x: 42 - subprocess.call(['/usr/bin/pkill', '-u', os.environ['USER']]) diff --git a/src/opengnsys/macos/operations.py b/src/opengnsys/macos/operations.py index 5f827a1..24022d9 100644 --- a/src/opengnsys/macos/operations.py +++ b/src/opengnsys/macos/operations.py @@ -41,7 +41,6 @@ import ctypes.util import subprocess import struct import array -import six import json from opengnsys import utils @@ -134,11 +133,6 @@ def reboot(flags=0): ''' Simple reboot command ''' - # Workaround for dummy thread - if six.PY3 is False: - import threading - threading._DummyThread._Thread__stop = lambda x: 42 - # Exec reboot command subprocess.call('/sbin/shutdown -r now', shell=True) @@ -147,11 +141,6 @@ def poweroff(flags=0): ''' Simple poweroff command ''' - # Workaround for dummy thread - if six.PY3 is False: - import threading - threading._DummyThread._Thread__stop = lambda x: 42 - # Exec shutdown command subprocess.call('/sbin/shutdown -h now', shell=True) @@ -160,11 +149,6 @@ def logoff(): ''' Simple logout using AppleScript ''' - # Workaround for dummy thread - if six.PY3 is False: - import threading - threading._DummyThread._Thread__stop = lambda x: 42 - # Exec logout using AppleScript subprocess.call('/usr/bin/osascript -e \'tell app "System Events" to «event aevtrlgo»\'', shell=True) diff --git a/src/opengnsys/utils.py b/src/opengnsys/utils.py index c54b4b7..9df7a89 100644 --- a/src/opengnsys/utils.py +++ b/src/opengnsys/utils.py @@ -32,7 +32,6 @@ import sys -import six if sys.platform == 'win32': _fromEncoding = 'windows-1250' @@ -42,15 +41,15 @@ else: def toUnicode(msg): try: - if not isinstance(msg, six.text_type): - if isinstance(msg, six.binary_type): + if not isinstance(msg, str): + if isinstance(msg, bytes): return msg.decode(_fromEncoding, 'ignore') - return six.text_type(msg) + return str(msg) else: return msg except Exception: try: - return six.text_type(msg) + return str(msg) except Exception: return '' diff --git a/src/requirements.txt b/src/requirements.txt index b85c90d..29bf5af 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -1,6 +1,6 @@ pywin32 pyqt6 requests -six + pycryptodome pyinstaller