This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository python-x2go. commit cf364ae1a41c63ff7f980ff818d261de7c599244 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Fri Jul 19 17:06:16 2019 +0200 X2GoSessionInfo: Handle non-initialized X2GoSessionInfo instance more gracefully. --- debian/changelog | 2 ++ x2go/backends/info/plain.py | 77 +++++++++++++++++++++++++++++++-------------- 2 files changed, 55 insertions(+), 24 deletions(-) diff --git a/debian/changelog b/debian/changelog index cb518ec..03b997e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ python-x2go (0.6.0.3-0x2go1) UNRELEASED; urgency=medium [ Mike Gabriel ] * New upstream version (0.6.0.3): - X2GoSessionInfo: Drop debug print command. + - X2GoSessionInfo: Handle non-initialized X2GoSessionInfo instance + more gracefully. -- X2Go Release Manager <git-admin@x2go.org> Sat, 01 Dec 2018 02:16:45 +0100 diff --git a/x2go/backends/info/plain.py b/x2go/backends/info/plain.py index 222cfff..c2be45f 100644 --- a/x2go/backends/info/plain.py +++ b/x2go/backends/info/plain.py @@ -42,10 +42,14 @@ class X2GoServerSessionInfo(object): that is retrieved from the connected X2Go server on ``X2GoTerminalSession.start()`` resp. ``X2GoTerminalSession.resume()``. - """ + def __init__(self): + self.initialized = False + self.protected = False + def __str__(self): return self.name + def __repr__(self): result = 'X2GoServerSessionInfo(' for p in dir(self): @@ -78,6 +82,7 @@ class X2GoServerSessionInfo(object): self.username = l[11] self.sshfs_port = int(l[13]) self.local_container = '' + self.initialized = True except IndexError as e: # DEBUGGING CODE raise e @@ -102,10 +107,13 @@ class X2GoServerSessionInfo(object): :returns: returns ``True`` if this session is a published applications provider - :rtype: ``bool`` + :rtype: ``bool`` or ``None`` (if not initialized) """ - return bool(re.match('.*_stRPUBLISHED_.*', self.name)) + if self.initialized: + return bool(re.match('.*_stRPUBLISHED_.*', self.name)) + else: + return None def is_running(self): """\ @@ -114,10 +122,13 @@ class X2GoServerSessionInfo(object): :returns: ``True`` if the session is running, ``False`` otherwise - :rtype: ``bool`` + :rtype: ``bool`` or ``None`` (if not initialized) """ - return self.status == 'R' + if self.initialized: + return self.status == 'R' + else: + return None def get_session_type(self): """\ @@ -126,14 +137,17 @@ class X2GoServerSessionInfo(object): :returns: session type - :rtype: ``str`` + :rtype: ``str`` or ``None`` (if not initialized) """ - cmd = self.name.split('_')[1] - session_type = cmd[2] - if session_type == 'R' and self.is_published_applications_provider(): - session_type = 'P' - return session_type + if self.initialized: + cmd = self.name.split('_')[1] + session_type = cmd[2] + if session_type == 'R' and self.is_published_applications_provider(): + session_type = 'P' + return session_type + else: + return None def get_share_mode(self): """\ @@ -142,15 +156,18 @@ class X2GoServerSessionInfo(object): :returns: share mode (0: view-only, 1: full access), ``None`` when used for non-desktop-sharing sessions - :rtype: ``str`` + :rtype: ``str`` or ``None`` (if not initialized) """ - share_mode = None - cmd = self.name.split('_')[1] - session_type = cmd[2] - if session_type == 'S': - share_mode = cmd[3] - return share_mode + if self.initialized: + share_mode = None + cmd = self.name.split('_')[1] + session_type = cmd[2] + if session_type == 'S': + share_mode = cmd[3] + return share_mode + else: + return None def is_suspended(self): """\ @@ -159,10 +176,13 @@ class X2GoServerSessionInfo(object): :returns: ``True`` if the session is suspended, ``False`` otherwise - :rtype: ``bool`` + :rtype: ``bool`` or ``None`` (if not initialized) """ - return self.status == 'S' + if self.initialized: + return self.status == 'S' + else: + return None def is_desktop_session(self): """\ @@ -171,10 +191,13 @@ class X2GoServerSessionInfo(object): :returns: ``True`` if this session is a desktop session, ``False`` otherwise - :rtype: ``bool`` + :rtype: ``bool`` or ``None`` (if not initialized) """ - return self.get_session_type() == 'D' + if self.initialized: + return self.get_session_type() == 'D' + else: + return None def _parse_x2gostartagent_output(self, x2go_output): """\ @@ -202,6 +225,7 @@ class X2GoServerSessionInfo(object): self.status = 'R' self.local_container = '' self.remote_container = '' + self.initialized = True except IndexError as e: # DEBUGGING CODE raise e @@ -242,6 +266,7 @@ class X2GoServerSessionInfo(object): self.hostname = hostname self.local_container = local_container self.remote_container = remote_container + self.initialized = True def protect(self): """\ @@ -274,10 +299,13 @@ class X2GoServerSessionInfo(object): :returns: session status - :rtype: ``str`` + :rtype: ``str`` or ``None`` (if not initalized) """ - return self.status + if self.initialized: + return self.status + else: + return None def clear(self): """\ @@ -302,6 +330,7 @@ class X2GoServerSessionInfo(object): self.local_container = '' self.remote_container = '' self.protected = False + self.initialized = False def update(self, session_info): """\ -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/python-x2go.git