Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 33 by [email protected]: Put File fails when destination path is a Windows Path
http://code.google.com/p/robotframework-sshlibrary/issues/detail?id=33

Let's say you have this test:

*** Settings ***
Library         SSHLibrary

*** Variables ***
${HOST}         <SOME IP>
${USERNAME}     <SOME USER>
${PWD}          <SOME PWD>

*** Test Cases ***
Failing to copy a file on a Windows machine
  Open Connection  ${HOST}
  Login  ${USERNAME}  ${PWD}
  Put File      test.txt        c:\\windows\\temp\\test.txt
  Close Connection


When you run this with Robot Framework you get something alone:

KEYWORD: SSHLibrary.Put File test.txt, c:\\windows\\temp\\test.txt
Documentation: Copies file(s) from local host to remote host using existing SSH connection. Start / End / Elapsed: 20110727 16:01:42.091 / 20110727 16:01:42.183 / 00:00:00.092
16:01:42.164    INFO    Creating missing remote directory 'windows'
16:01:42.183 FAIL IOError: [Errno 2] The file path does not exist or is invalid.



Now if you take this:

from SSHLibrary import SSHLibrary

__all__ = ['SSHLib']

class SSHLib(SSHLibrary):
    ROBOT_LIBRARY_SCOPE = 'GLOBAL'

def put_one_file(self, source, destination='.', mode='0744', newlines='default'):
        self._client.create_sftp_client()
        try:
            self._info("Putting '%s' to '%s'" % (source, destination))
            self._client.put_file(source, destination, int(mode, 8),
{'CRLF': '\r\n', 'LF': '\n'}.get(newlines, None))
        finally:
            self._client.close_sftp_client()
                        
if __name__ == '__main__':
        ssh = SSHLib()
        ssh.open_connection("192.168.0.66")
        ssh.login("test", "test")
        ssh.put_one_file("test.txt", "c:\\windows\\temp\\test.txt")
        ssh.close_connection()


It will succeed copying the file.

It appears that the top-level Put File keyword performs some operations on the path that aren't handled well with Windows.


Python 2.7
Robot Framework 2.5.7
SSH Library 1.0
Paramiko 1.7.7.1
PyCrypto 2.3
Windows 2008



Reply via email to