3 new revisions:
Revision: 3e170054da29
Author: Anssi Syrjäsalo <anssi.syrjas...@eficode.com>
Date: Tue Jul 30 02:43:12 2013
Log: Fixed local tmp path
http://code.google.com/p/robotframework-sshlibrary/source/detail?r=3e170054da29
Revision: 8c413113a27d
Author: Anssi Syrjäsalo <anssi.syrjas...@eficode.com>
Date: Tue Jul 30 02:43:29 2013
Log: Disabled logging for a test
http://code.google.com/p/robotframework-sshlibrary/source/detail?r=8c413113a27d
Revision: 05c4ccc30bd3
Author: Anssi Syrjäsalo <anssi.syrjas...@eficode.com>
Date: Tue Jul 30 03:56:32 2013
Log: Put Dir and Get Dir not recursive by default. Option added.
http://code.google.com/p/robotframework-sshlibrary/source/detail?r=05c4ccc30bd3
==============================================================================
Revision: 3e170054da29
Author: Anssi Syrjäsalo <anssi.syrjas...@eficode.com>
Date: Tue Jul 30 02:43:12 2013
Log: Fixed local tmp path
http://code.google.com/p/robotframework-sshlibrary/source/detail?r=3e170054da29
Modified:
/atest/get_file.txt
=======================================
--- /atest/get_file.txt Mon Jul 29 08:40:05 2013
+++ /atest/get_file.txt Tue Jul 30 02:43:12 2013
@@ -39,10 +39,10 @@
[Teardown] Remove Tmp Dir And Remote File
Get File To Absolute Destination
- SSHLibrary.Get File ${TEST SCRIPT NAME} ${CURDIR}${/}${LOCAL
TMPDIR}${/}
- ${contents} = List Directory ${CURDIR}${/}${LOCAL TMPDIR}${/}
+ SSHLibrary.Get File ${TEST SCRIPT NAME} ${LOCAL TMPDIR}${/}
+ ${contents} = List Directory ${LOCAL TMPDIR}${/}
Should Contain ${contents} ${TEST SCRIPT NAME}
- [Teardown] Remove Directory ${CURDIR}${/}${LOCAL TMPDIR} yes
+ [Teardown] Remove Directory ${LOCAL TMPDIR} yes
Get File Should Fail When There Are No Source Files
Run Keyword And Expect Error There were no source files
matching 'non-existing' SSHLibrary.Get File non-existing
==============================================================================
Revision: 8c413113a27d
Author: Anssi Syrjäsalo <anssi.syrjas...@eficode.com>
Date: Tue Jul 30 02:43:29 2013
Log: Disabled logging for a test
http://code.google.com/p/robotframework-sshlibrary/source/detail?r=8c413113a27d
Modified:
/atest/put_file.txt
=======================================
--- /atest/put_file.txt Mon Jul 29 08:40:05 2013
+++ /atest/put_file.txt Tue Jul 30 02:43:29 2013
@@ -69,9 +69,8 @@
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
+Put File With Special Chars In File Name
[Documentation]
http://code.google.com/p/robotframework-sshlibrary/issues/detail?id=55
- Enable SSH Logging ${LOCAL TMPDIR}${/}ssh_log.txt
Put File ${FILE WITH SPECIAL CHARS} ${USER HOME}/robotdir/
Verify Remote Files Exist robotdir foo%2Fbar.txt
[Teardown] Execute Command rm -rf robotdir
==============================================================================
Revision: 05c4ccc30bd3
Author: Anssi Syrjäsalo <anssi.syrjas...@eficode.com>
Date: Tue Jul 30 03:56:32 2013
Log: Put Dir and Get Dir not recursive by default. Option added.
http://code.google.com/p/robotframework-sshlibrary/source/detail?r=05c4ccc30bd3
Modified:
/atest/get_dir.txt
/atest/put_dir.txt
/src/SSHLibrary/abstractclient.py
/src/SSHLibrary/library.py
=======================================
--- /atest/get_dir.txt Mon Jul 29 08:40:05 2013
+++ /atest/get_dir.txt Tue Jul 30 03:56:32 2013
@@ -2,27 +2,48 @@
Force Tags pybot jybot
Suite Setup Login and Move Test Files
Suite Teardown Remove Test Files and Close Connections
+Test Teardown Remove Directory ${LOCAL TMPDIR} True
Resource resources/ssh_library_resources.txt
Library OperatingSystem
Library Collections
*** Test Cases ***
Get Dir Using Absolute Source
- Get Dir And Verify Content ${USER HOME}/test_root ${LOCAL TMPDIR}
- [Teardown] Remove Directory ${LOCAL TMPDIR} True
+ ${target} = Set Variable ${LOCAL TMPDIR}
+ Directory Should Not Exist ${target}
+ SSHLibrary.Get Dir ${USER HOME}/test_root ${target}
+ Directory Should Exist With Content ${target}
Get Dir Using Relative Source
- Get Dir And Verify Content test_root ${LOCAL TMPDIR}
- [Teardown] Remove Directory ${LOCAL TMPDIR} True
+ ${target} = Set Variable ${LOCAL TMPDIR}
+ Directory Should Not Exist ${target}
+ SSHLibrary.Get Dir test_root ${target}
+ Directory Should Exist With Content ${target}
Get Dir Using Different Name
- Get Dir And Verify Content ${USER HOME}/test_root ${LOCAL
TMPDIR}${/}foo
- [Teardown] Remove Directory ${LOCAL TMPDIR} True
+ ${target} = Set Variable ${LOCAL TMPDIR}${/}foo
+ Directory Should Not Exist ${target}
+ SSHLibrary.Get Dir ${USER HOME}/test_root ${target}
+ Directory Should Exist With Content ${target}
+
+Get Dir With Subdirectories
+ ${target} = Set Variable ${LOCAL TMPDIR}
+ Directory Should Not Exist ${target}
+ SSHLibrary.Get Dir ${USER HOME}/test_root ${target} recursive=True
+ Directory Should Exist Including Subdirectories ${target}
*** Keywords ***
-Get Dir And Verify Content
- [Arguments] ${source} ${destination}
- SSHLibrary.Get Dir ${source} ${destination}
+Directory Should Exist With Content
+ [Arguments] ${destination}
+ ${target_path} = List Directory ${destination}
+ ${expected} = Create List test_root
+ Lists Should Be Equal ${target_path} ${expected}
+ ${test_root} = List Directory ${destination}/test_root
+ ${expected} = Create List ${TEST SCRIPT NAME} ${REPEAT TEST SCRIPT
NAME}
+ Lists Should Be Equal ${test_root} ${expected}
+
+Directory Should Exist Including Subdirectories
+ [Arguments] ${destination}
${target_path} = List Directory ${destination}
${expected} = Create List test_root
Lists Should Be Equal ${target_path} ${expected}
=======================================
--- /atest/put_dir.txt Mon Jul 29 07:18:01 2013
+++ /atest/put_dir.txt Tue Jul 30 03:56:32 2013
@@ -2,38 +2,55 @@
Force Tags pybot jybot
Suite Setup Login As Valid User
Suite Teardown Close All Connections
+Test Teardown Execute Command rm -rf ${target}
Resource resources/ssh_library_resources.txt
*** Test Cases ***
Put Dir With Absolute Destination
- Put Dir And Verify ${TEXTFILES} ${USER HOME}/new_dir/ ${USER
HOME}/new_dir/textfiles
- [Teardown] Execute Command rm -rf ${USER HOME}/new_dir
+ ${target} = Set Variable ${USER HOME}/new_dir/
+ Remote Directory Should Not Exist ${target}
+ Put Dir ${TEXTFILES} ${target}
+ Remote Directory Should Exist With Content ${target}/textfiles
Put Dir With Relative Destination
- Put Dir And Verify ${TEXTFILES} new_dir/ ${USER
HOME}/new_dir/textfiles
- [Teardown] Execute Command rm -rf ${USER HOME}/new_dir
+ ${target} = Set Variable new_dir/
+ Remote Directory Should Not Exist ${target}
+ Put Dir ${TEXTFILES} ${target}
+ Remote Directory Should Exist With Content ${target}/textfiles
Put Dir To Home Directory
- Put Dir And Verify ${TEXTFILES} ./ ${USER HOME}/textfiles
- [Teardown] Execute Command rm -rf ${USER HOME}/textfiles
+ ${target} = Set Variable ./textfiles
+ Remote Directory Should Not Exist ${target}
+ Put Dir ${TEXTFILES} ./
+ Remote Directory Should Exist With Content ${target}
Put Dir With Different Name
- Put Dir And Verify ${TEXTFILES} ${USER HOME}/another_dir_name
${USER HOME}/another_dir_name
- [Teardown] Execute Command rm -rf ${USER HOME}/another_dir_name
+ ${target} = Set Variable ${USER HOME}/another_dir_name
+ Remote Directory Should Not Exist ${target}
+ Put Dir ${TEXTFILES} ${target}
+ Remote Directory Should Exist With Content ${target}
+
+Put Dir With Subdirectories
+ ${target} = Set Variable ${USER HOME}/new_dir/
+ Remote Directory Should Not Exist ${target}
+ Put Dir ${TEXTFILES} ${target} recursive=True
+ Remote Directory Should Exist With Subdirectories ${target}/textfiles
*** Keywords ***
-Put Dir And Verify
- [Arguments] ${source} ${destination} ${expected}
- Verify Remote Dir Does Not Exist ${expected}
- Put Dir ${source} ${destination}
- Verify Remote Dir Structure Exists ${expected}
+Remote Directory Should Not Exist
+ [Arguments] ${expected}
+ ${rc} = Execute Command test -d ${expected} return_stdout=${false}
return_rc=${true}
+ Should Be Equal As Integers ${rc} 1
-Verify Remote Dir Does Not Exist
+Remote Directory Should Exist With Content
[Arguments] ${expected}
${stdout} = Execute Command ls ${expected}
- Should Not Contain ${stdout} ${expected}
+ Should Contain ${stdout} ${TEST FILE NAME}
+ Should Contain ${stdout} ${TEST FILE 2 NAME}
+ Should Contain ${stdout} ${FILE WITH NEWLINES NAME}
+ Should Not Contain ${stdout} special
-Verify Remote Dir Structure Exists
+Remote Directory Should Exist With Subdirectories
[Arguments] ${expected}
${stdout} = Execute Command ls ${expected}
Should Contain ${stdout} ${TEST FILE NAME}
=======================================
--- /src/SSHLibrary/abstractclient.py Mon Jul 29 06:29:29 2013
+++ /src/SSHLibrary/abstractclient.py Tue Jul 30 03:56:32 2013
@@ -272,11 +272,12 @@
sftp_client.close()
return sources, destinations
- def put_dir(self, source, destination='.', mode='0744',
- newline='default', path_separator='/'):
+ def put_dir(self, source, destination='.', mode='0744',
newline='default',
+ path_separator='/', recursive=False):
sftp_client = self._create_sftp_client()
sources, destinations = sftp_client.put_dir(source, destination,
mode,
- newline,
path_separator)
+ newline,
path_separator,
+ recursive)
sftp_client.close()
return sources, destinations
@@ -296,10 +297,11 @@
sftp_client.close()
return sources, destinations
- def get_dir(self, source, destination='.', path_separator='/'):
+ def get_dir(self, source, destination='.', path_separator='/',
+ recursive=False):
sftp_client = self._create_sftp_client()
sources, destinations = sftp_client.get_dir(source, destination,
- path_separator)
+ path_separator,
recursive)
sftp_client.close()
return sources, destinations
@@ -313,13 +315,14 @@
def close(self):
self._client.close()
- def get_dir(self, source, destination, path_separator='/'):
+ def get_dir(self, source, destination, path_separator='/',
recursive=False):
remotefiles = []
localfiles = []
subdirs = [os.path.basename(source)]
for path in subdirs:
- [subdirs.append(path_separator.join([path, subdir_name]))
- for subdir_name in self._listdirs(path)]
+ if recursive:
+ [subdirs.append(path_separator.join([path, subdir_name]))
+ for subdir_name in self._listdirs(path)]
remote_path = path + path_separator + "*"
local_path = os.path.join(destination, path) + path_separator
r, l = self.get_file(remote_path, local_path, path_separator)
@@ -372,28 +375,32 @@
if not os.path.exists(dest):
os.makedirs(dest)
- def put_dir(self, source, destination, mode, newline,
path_separator='/'):
+ def put_dir(self, source, destination, mode, newline,
path_separator='/',
+ recursive=False):
os.chdir(os.path.dirname(source))
parent = os.path.basename(source)
localfiles = []
remotefiles = []
- for path, _, files in os.walk(parent):
- for file in files:
- local_path = os.path.join(path, file)
+ for dirpath, _, filenames in os.walk(parent):
+ for filename in filenames:
+ local_path = os.path.join(dirpath, filename)
if destination.endswith('./'):
- remote_path = path_separator.join([path, file])
+ remote_path = path_separator.join([dirpath, filename])
elif destination.endswith('/'):
- remote_path = path_separator.join([destination[:-1],
path,
- file])
+ remote_path = path_separator.join([destination[:-1],
+ dirpath,
+ filename])
else:
- path_without_parent = path.replace(parent, '')
+ path_without_parent = dirpath.replace(parent, '')
remote_path = path_separator.join([destination,
path_without_parent,
- file])
+ filename])
l, r = self.put_file(local_path, remote_path, mode,
newline,
path_separator)
localfiles.extend(l)
remotefiles.extend(r)
+ if not recursive:
+ break
return localfiles, remotefiles
def put_file(self, sources, destination, mode, newline,
@@ -401,8 +408,9 @@
mode = int(mode, 8)
newline = {'CRLF': '\r\n', 'LF': '\n'}.get(newline.upper(), None)
localfiles = self._get_put_file_sources(sources)
- remotefiles, remotedir = self._get_put_file_destinations(
- localfiles, destination, path_separator)
+ remotefiles, remotedir =
self._get_put_file_destinations(localfiles,
+
destination,
+
path_separator)
self._create_missing_remote_path(remotedir)
for src, dst in zip(localfiles, remotefiles):
self._put_file(src, dst, mode, newline)
=======================================
--- /src/SSHLibrary/library.py Thu Jul 25 07:09:43 2013
+++ /src/SSHLibrary/library.py Tue Jul 30 03:56:32 2013
@@ -608,9 +608,10 @@
return self._run_sftp_command(self.ssh_client.get_file, source,
destination, path_separator)
- def get_dir(self, source, destination='.', path_separator='/'):
+ def get_dir(self, source, destination='.', path_separator='/',
+ recursive=False):
return self._run_sftp_command(self.ssh_client.get_dir, source,
- destination, path_separator)
+ destination, path_separator,
recursive)
def put_file(self, source, destination='.', mode='0744',
newline='default', path_separator='/'):
@@ -659,11 +660,11 @@
destination, mode, newline,
path_separator)
- def put_dir(self, source, destination='.', mode='0744',
- newline='default', path_separator='/'):
+ def put_dir(self, source, destination='.', mode='0744',
newline='default',
+ path_separator='/', recursive=False):
return self._run_sftp_command(self.ssh_client.put_dir, source,
destination, mode, newline,
- path_separator)
+ path_separator, recursive)
def _run_sftp_command(self, command, *args):
try:
--
---
You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.