This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository python-x2go. commit bf1fb49187a2e3f6d5ce65e8dae770690a9ef82b Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Tue Oct 14 21:13:41 2014 +0200 python-x2go.spec: Avoid duplicate files in openSUSE/SLES. --- debian/changelog | 1 + python-x2go.spec | 4 ++ x2go/backends/control/plain.py | 126 +++++++++++++++++++++++++++++----------- 3 files changed, 97 insertions(+), 34 deletions(-) diff --git a/debian/changelog b/debian/changelog index 145425c..916223d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -119,6 +119,7 @@ python-x2go (0.5.0.0-0x2go1) UNRELEASED; urgency=low + Add S (python-x2go): telekinesis-client, mteleplayer-clientside. * python-x2go.spec: + Add dependencies: python-requests, python-simplejson. + + Additionally adapt to building on openSUSE/SLES. [ Mike DePaulo ] * New upstream version (0.5.0.0): diff --git a/python-x2go.spec b/python-x2go.spec index 26c1219..2dfe51b 100644 --- a/python-x2go.spec +++ b/python-x2go.spec @@ -19,6 +19,7 @@ Source0: http://code.x2go.org/releases/source/%{name}/%{name}-%{version}. BuildArch: noarch %if 0%{?suse_version} BuildRequires: python-devel +BuildRequires: fdupes %else BuildRequires: python2-devel %endif @@ -113,6 +114,9 @@ pushd %{py3dir} popd %endif # with_python3 %{__python} setup.py install --skip-build --root %{buildroot} +%if 0%{?fdupes:1} +%fdupes %buildroot/%_prefix +%endif %files diff --git a/x2go/backends/control/plain.py b/x2go/backends/control/plain.py index 6dfe924..093d5c6 100644 --- a/x2go/backends/control/plain.py +++ b/x2go/backends/control/plain.py @@ -276,7 +276,7 @@ class X2GoControlSession(paramiko.SSHClient): except (AttributeError, paramiko.SFTPError): raise x2go_exceptions.X2GoSFTPClientException('failed to initialize SFTP channel') - def _x2go_sftp_put(self, local_path, remote_path): + def _x2go_sftp_put(self, local_path, remote_path, timeout=20): """ Put a local file on the remote server via sFTP. @@ -286,6 +286,8 @@ class X2GoControlSession(paramiko.SSHClient): @type local_path: C{str} @param remote_path: full remote path name of the server-side target location, path names have to be Unix-compliant @type remote_path: C{str} + @param timeout: this SFTP put action should not take longer then the given value + @type timeout: C{int} @raise X2GoControlSessionException: if the SSH connection dropped out @@ -294,22 +296,38 @@ class X2GoControlSession(paramiko.SSHClient): self._transport_lock.acquire() if ssh_transport and ssh_transport.is_authenticated(): self.logger('sFTP-put: %s -> %s:%s' % (os.path.normpath(local_path), self.remote_peername(), remote_path), loglevel=log.loglevel_DEBUG) + + if self.low_latency: timeout = timeout * 2 + timer = gevent.Timeout(timeout) + timer.start() + try: - self.sftp_client = paramiko.SFTPClient.from_transport(ssh_transport) - except paramiko.SFTPError: - self._transport_lock.release() - raise x2go_exceptions.X2GoSFTPClientException('failed to initialize SFTP channel') - try: - self.sftp_client.put(os.path.normpath(local_path), remote_path) - except (x2go_exceptions.SSHException, socket.error, IOError): - # react to connection dropped error for SSH connections + try: + self.sftp_client = paramiko.SFTPClient.from_transport(ssh_transport) + except paramiko.SFTPError: + self._transport_lock.release() + raise x2go_exceptions.X2GoSFTPClientException('failed to initialize SFTP channel') + try: + self.sftp_client.put(os.path.normpath(local_path), remote_path) + except (x2go_exceptions.SSHException, socket.error, IOError): + # react to connection dropped error for SSH connections + self.session_died = True + self._transport_lock.release() + raise x2go_exceptions.X2GoControlSessionException('The SSH connection was dropped during an sFTP put action.') + + except gevent.timeout.Timeout: self.session_died = True self._transport_lock.release() - raise x2go_exceptions.X2GoControlSessionException('The SSH connection was dropped during an sFTP put action.') + if self.sshproxy_session: + self.sshproxy_session.stop_thread() + raise x2go_exceptions.X2GoControlSessionException('the X2Go control session timed out during an SFTP write command') + finally: + timer.cancel() + self.sftp_client = None self._transport_lock.release() - def _x2go_sftp_write(self, remote_path, content): + def _x2go_sftp_write(self, remote_path, content, timeout=20): """ Create a text file on the remote server via sFTP. @@ -319,6 +337,8 @@ class X2GoControlSession(paramiko.SSHClient): @type remote_path: C{str} @param content: a text file, multi-line files use Unix-link EOL style @type content: C{str} + @param timeout: this SFTP write action should not take longer then the given value + @type timeout: C{int} @raise X2GoControlSessionException: if the SSH connection dropped out @@ -327,25 +347,43 @@ class X2GoControlSession(paramiko.SSHClient): self._transport_lock.acquire() if ssh_transport and ssh_transport.is_authenticated(): self.logger('sFTP-write: opening remote file %s on host %s for writing' % (remote_path, self.remote_peername()), loglevel=log.loglevel_DEBUG) + + if self.low_latency: timeout = timeout * 2 + timer = gevent.Timeout(timeout) + timer.start() + try: - self.sftp_client = paramiko.SFTPClient.from_transport(ssh_transport) - except paramiko.SFTPError: - self._transport_lock.release() - raise x2go_exceptions.X2GoSFTPClientException('failed to initialize SFTP channel') - try: - remote_fileobj = self.sftp_client.open(remote_path, 'w') - self.logger('sFTP-write: writing content: %s' % content, loglevel=log.loglevel_DEBUG_SFTPXFER) - remote_fileobj.write(content) - remote_fileobj.close() - except (x2go_exceptions.SSHException, socket.error, IOError): + try: + self.sftp_client = paramiko.SFTPClient.from_transport(ssh_transport) + except paramiko.SFTPError: + self._transport_lock.release() + raise x2go_exceptions.X2GoSFTPClientException('failed to initialize SFTP channel') + try: + remote_fileobj = self.sftp_client.open(remote_path, 'w') + self.logger('sFTP-write: writing content: %s' % content, loglevel=log.loglevel_DEBUG_SFTPXFER) + remote_fileobj.write(content) + remote_fileobj.close() + except (x2go_exceptions.SSHException, socket.error, IOError): + self.session_died = True + self._transport_lock.release() + self.logger('sFTP-write: opening remote file %s on host %s failed' % (remote_path, self.remote_peername()), loglevel=log.loglevel_WARN) + if self.sshproxy_session: + self.sshproxy_session.stop_thread() + raise x2go_exceptions.X2GoControlSessionException('The SSH connection was dropped during an sFTP write action.') + + except gevent.timeout.Timeout: self.session_died = True self._transport_lock.release() - self.logger('sFTP-write: opening remote file %s on host %s failed' % (remote_path, self.remote_peername()), loglevel=log.loglevel_WARN) - raise x2go_exceptions.X2GoControlSessionException('The SSH connection was dropped during an sFTP write action.') + if self.sshproxy_session: + self.sshproxy_session.stop_thread() + raise x2go_exceptions.X2GoControlSessionException('the X2Go control session timed out during an SFTP write command') + finally: + timer.cancel() + self.sftp_client = None self._transport_lock.release() - def _x2go_sftp_remove(self, remote_path): + def _x2go_sftp_remove(self, remote_path, timeout=20): """ Remote a remote file from the server via sFTP. @@ -353,6 +391,8 @@ class X2GoControlSession(paramiko.SSHClient): @param remote_path: full remote path name of the server-side file to be removed, path names have to be Unix-compliant @type remote_path: C{str} + @param timeout: this SFTP remove action should not take longer then the given value + @type timeout: C{int} @raise X2GoControlSessionException: if the SSH connection dropped out @@ -361,18 +401,36 @@ class X2GoControlSession(paramiko.SSHClient): self._transport_lock.acquire() if ssh_transport and ssh_transport.is_authenticated(): self.logger('sFTP-write: removing remote file %s on host %s' % (remote_path, self.remote_peername()), loglevel=log.loglevel_DEBUG) + + if self.low_latency: timeout = timeout * 2 + timer = gevent.Timeout(timeout) + timer.start() + try: - self.sftp_client = paramiko.SFTPClient.from_transport(ssh_transport) - except paramiko.SFTPError: - self._transport_lock.release() - raise x2go_exceptions.X2GoSFTPClientException('failed to initialize SFTP channel') - try: - self.sftp_client.remove(remote_path) - except (x2go_exceptions.SSHException, socket.error, IOError): + try: + self.sftp_client = paramiko.SFTPClient.from_transport(ssh_transport) + except paramiko.SFTPError: + self._transport_lock.release() + raise x2go_exceptions.X2GoSFTPClientException('failed to initialize SFTP channel') + try: + self.sftp_client.remove(remote_path) + except (x2go_exceptions.SSHException, socket.error, IOError): + self.session_died = True + self._transport_lock.release() + self.logger('sFTP-write: removing remote file %s on host %s failed' % (remote_path, self.remote_peername()), loglevel=log.loglevel_WARN) + if self.sshproxy_session: + self.sshproxy_session.stop_thread() + raise x2go_exceptions.X2GoControlSessionException('The SSH connection was dropped during an sFTP remove action.') + + except gevent.timeout.Timeout: self.session_died = True self._transport_lock.release() - self.logger('sFTP-write: removing remote file %s on host %s failed' % (remote_path, self.remote_peername()), loglevel=log.loglevel_WARN) - raise x2go_exceptions.X2GoControlSessionException('The SSH connection was dropped during an sFTP remove action.') + if self.sshproxy_session: + self.sshproxy_session.stop_thread() + raise x2go_exceptions.X2GoControlSessionException('the X2Go control session timed out during an SFTP write command') + finally: + timer.cancel() + self.sftp_client = None self._transport_lock.release() @@ -461,7 +519,7 @@ class X2GoControlSession(paramiko.SSHClient): else: self._transport_lock.release() - raise x2go_exceptions.X2GoControlSessionException('the X2Go control session is not connected') + raise x2go_exceptions.X2GoControlSessionException('the X2Go control session is not connected (while issuing SSH command=%s)' % cmd) self._transport_lock.release() -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/python-x2go.git