Revision: 182
Author:   janne.t.harkonen
Date:     Thu Aug 30 00:50:42 2012
Log:      Workaround for Paramiko log bug.

Update issue 55
Status: Done
Owner: janne.t.harkonen
http://code.google.com/p/robotframework-sshlibrary/source/detail?r=182

Added:
 /trunk/atest/resources/scripts/foo%2Fbar.txt
Modified:
 /trunk/atest/put_file.txt
 /trunk/atest/resources/ssh_library_resources.txt
 /trunk/src/SSHLibrary/pythonclient.py

=======================================
--- /dev/null
+++ /trunk/atest/resources/scripts/foo%2Fbar.txt        Thu Aug 30 00:50:42 2012
@@ -0,0 +1,1 @@
+This is a test file used in Get File and Put File tests.
=======================================
--- /trunk/atest/put_file.txt   Mon Aug 27 05:07:10 2012
+++ /trunk/atest/put_file.txt   Thu Aug 30 00:50:42 2012
@@ -64,6 +64,13 @@
 Put File Should Fail When There Are No Source Files
Run Keyword And Expect Error There are no source files matching 'non*existing' SSHLibrary.Put File non*existing

+Put File with special characters in filename
+ [Documentation] http://code.google.com/p/robotframework-sshlibrary/issues/detail?id=55
+    Enable SSH Logging     ${TEMPDIR}${/}ssh_log.txt
+    Put File  ${SPECIAL CHARS FILE}  /home/${USERNAME}/robotdir/
+    Verify Remote Files Exist  robotdir  foo%2Fbar.txt
+    [Teardown]  Execute Command  rm -rf robotdir
+
 *** Keywords ***
 Put Files And Verify
     [Arguments]  ${source}  ${destination}  @{expected}
=======================================
--- /trunk/atest/resources/ssh_library_resources.txt Sun Nov 7 23:24:19 2010 +++ /trunk/atest/resources/ssh_library_resources.txt Thu Aug 30 00:50:42 2012
@@ -19,6 +19,7 @@
 ${TEST FILE PATTERN}  ${SCRIPTS}test*.txt
 ${FILE WITH NEWLINES NAME}  file_with_newlines.txt
 ${FILE WITH NEWLINES}  ${SCRIPTS}${FILE WITH NEWLINES NAME}
+${SPECIAL CHARS FILE}  ${SCRIPTS}foo%2Fbar.txt

 *** Keywords ***
 Login And Move Test Files
=======================================
--- /trunk/src/SSHLibrary/pythonclient.py       Wed Aug 29 05:46:34 2012
+++ /trunk/src/SSHLibrary/pythonclient.py       Thu Aug 30 00:50:42 2012
@@ -32,9 +32,22 @@
     self._orig_start_client(event)


+# See http://code.google.com/p/robotframework-sshlibrary/issues/detail?id=55
+def _monkey_patched_log(self, level, msg, *args):
+    escape = lambda s: s.replace('%', '%%')
+    if isinstance(msg, basestring):
+        msg = escape(msg)
+    else:
+        msg = [escape(m) for m in msg]
+    return self._orig_log(level, msg, *args)
+
+
 paramiko.transport.Transport._orig_start_client = \
         paramiko.transport.Transport.start_client
 paramiko.transport.Transport.start_client = _monkey_patched_start_client
+paramiko.sftp_client.SFTPClient._orig_log = \
+        paramiko.sftp_client.SFTPClient._log
+paramiko.sftp_client.SFTPClient._log = _monkey_patched_log


 class PythonSSHClient(AbstractSSHClient):

Reply via email to