[X2Go-Commits] python-x2go.git - build-baikal (branch) updated: 37bd2638fb99223db836a5375db0026c1f60df84

X2Go dev team git-admin at x2go.org
Wed Jan 8 15:25:40 CET 2014


The branch, build-baikal has been updated
       via  37bd2638fb99223db836a5375db0026c1f60df84 (commit)
      from  05dbe3742b2483b5c238960e3d2f7eac9c8228c4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 x2go/client.py     |    8 +++++++-
 x2go/pulseaudio.py |   27 +++++++++++++++++++--------
 2 files changed, 26 insertions(+), 9 deletions(-)

The diff of changes is:
diff --git a/x2go/client.py b/x2go/client.py
index 2ad5e71..70b3c24 100644
--- a/x2go/client.py
+++ b/x2go/client.py
@@ -230,6 +230,8 @@ class X2goClient(object):
         self.sessions_rootdir = sessions_rootdir or os.path.join(_LOCAL_HOME, _X2GO_SESSIONS_ROOTDIR)
         self.ssh_rootdir = ssh_rootdir or os.path.join(_LOCAL_HOME, _X2GO_SSH_ROOTDIR)
 
+        self.pulseaudio_installdir = pulseaudio_installdir
+
         if self.client_rootdir is not None:
             self._has_custom_client_rootdir = True
             _sessions_config_file = os.path.join(self.client_rootdir, _X2GO_SESSIONPROFILES_FILENAME)
@@ -263,7 +265,7 @@ class X2goClient(object):
                 os.environ.update({'DISPLAY': 'localhost:0'})
 
         if _X2GOCLIENT_OS == 'Windows' and start_pulseaudio:
-            self.pulseaudio = X2goPulseAudio(path=self.pulseaudio_installdir, logger=self.logger)
+            self.pulseaudio = X2goPulseAudio(path=self.pulseaudio_installdir, client_instance=self, logger=self.logger)
 
         self.auto_register_sessions = auto_register_sessions
         self.session_registry = X2goSessionRegistry(self, logger=self.logger)
@@ -291,6 +293,10 @@ class X2goClient(object):
         self.logger('HOOK_printaction_error: incoming print job ,, %s'' caused error: %s' % (filename, err_msg), loglevel=log.loglevel_ERROR)
     def HOOK_on_control_session_death(self, profile_name):
         self.logger('HOOK_on_control_session_death: the control session of profile %s has died unexpectedly' % profile_name, loglevel=log.loglevel_WARN)
+    def HOOK_pulseaudio_server_startup_failed(self):
+        self.logger('HOOK_pulseaudio_server_startup_failed: The pulseaudio daemon could not be started')
+    def HOOK_pulseaudio_server_died(self):
+        self.logger('HOOK_pulseaudio_server_died: The pulseaudio daemon has just died away')
     def HOOK_on_sound_tunnel_failed(self, profile_name='UNKNOWN', session_name='UNKNOWN'):
         self.logger('HOOK_on_sound_tunnel_failed: setting up X2go sound for %s (%s) support failed' % (profile_name, session_name))
 
diff --git a/x2go/pulseaudio.py b/x2go/pulseaudio.py
index d163afa..d48303e 100644
--- a/x2go/pulseaudio.py
+++ b/x2go/pulseaudio.py
@@ -17,9 +17,6 @@
 # Free Software Foundation, Inc.,
 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 #
-# This code was initially written by:
-#       2010 Dick Kniep <dick.kniep at lindix.nl>
-#
 # Other contributors:
 #       none so far
 
@@ -44,7 +41,7 @@ class X2goPulseAudio(threading.Thread):
     This class controls the Pulse Audio daemon.
     """
 
-    def __init__(self, path=None, logger=None, loglevel=log.loglevel_DEFAULT):
+    def __init__(self, path=None, client_instance=None, logger=None, loglevel=log.loglevel_DEFAULT):
         """\
         STILL UNDOCUMENTED
 
@@ -61,6 +58,7 @@ class X2goPulseAudio(threading.Thread):
         self.logger.tag = __NAME__
 
         self.path = path
+        self.client_instance = client_instance
         self._keepalive = None
 
         threading.Thread.__init__(self)
@@ -73,7 +71,7 @@ class X2goPulseAudio(threading.Thread):
 
         """
         self._keepalive = True
-        cmd = 'pulseaudio'
+        cmd = 'pulseaudio.exe'
         if self.path:
             cmd = os.path.join(self.path, cmd)
         cmd_options = [
@@ -84,10 +82,23 @@ class X2goPulseAudio(threading.Thread):
         ]
         cmd_line = [cmd]
         cmd_line.extend(cmd_options)
-        self.logger('starting PulsaAudio server with command line: %s' % ' '.join(cmd_line), loglevel=log.loglevel_DEBUG)
-        p = subprocess.Popen(cmd_line, shell=False)
-        while self._keepalive:
+        self.logger('starting PulseAudio server with command line: %s' % ' '.join(cmd_line), loglevel=log.loglevel_DEBUG)
+        p = subprocess.Popen(cmd_line,
+                             stdout=subprocess.PIPE,
+                             stderr=subprocess.STDOUT,
+                             shell=False,
+                            )
+        gevent.sleep(5)
+        _is_alive = p and (p.poll() is None)
+        if self.client_instance and not _is_alive:
+            self.client_instance.HOOK_pulseaudio_server_startup_failed()
+
+        while self._keepalive and _is_alive:
             gevent.sleep(1)
+            _is_alive =  p and (p.poll() is None)
+            if self.client_instance and not _is_alive:
+                self.client_instance.HOOK_pulseaudio_server_died()
+
         self.logger('terminating running PulseAudio server', loglevel=log.loglevel_DEBUG)
         try:
             p.terminate()


hooks/post-receive
-- 
python-x2go.git (Python X2Go Client API)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-x2go.git" (Python X2Go Client API).




More information about the x2go-commits mailing list