Re: [Freeipa-devel] [pytest-multihost-devel][PATCH] Functions for handling various file and directory operations

2015-11-26 Thread Petr Viktorin
On 11/26/2015 07:42 AM, Abhijeet Kasurde wrote:
> Hi Petr,
> 
> On 11/25/2015 08:27 PM, Petr Viktorin wrote:
>> On 11/25/2015 10:08 AM, Abhijeet Kasurde wrote:
>>> Hi All,
>>>
>>> Please find the patch for pytest-multihost-plugin.
>>>
>>> Fixes : https://fedorahosted.org/python-pytest-multihost/ticket/2
>> Thanks! These will be useful.
>>
>> ACK, pushed as e7bf95b3ba4ca84b73abffda1abcf6187c5c8a67
>> I wrote some tests for the file operations as well:
>> 5e76908430bbb56ca981b04a88f12359c73c7e1f
>>
> Thanks for adding testcases for these functions.
>> I plan to do a release (and update the Fedora package) after IPA starts
>> testing under Python 3. Let me know if an earlier release would help you.
> Yes, indeed. It will be very helpful. Let me know if you need any help
> for my side.

OK, the 0.9 release of python-pytest-multihost is now on PyPI and in
Rawhide. For Fedora 23 you can provide karma here:
https://bodhi.fedoraproject.org/updates/FEDORA-2015-f8ecd33065


-- 
Petr Viktorin

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] [pytest-multihost-devel][PATCH] Functions for handling various file and directory operations

2015-11-25 Thread Abhijeet Kasurde

Hi Petr,

On 11/25/2015 08:27 PM, Petr Viktorin wrote:

On 11/25/2015 10:08 AM, Abhijeet Kasurde wrote:

Hi All,

Please find the patch for pytest-multihost-plugin.

Fixes : https://fedorahosted.org/python-pytest-multihost/ticket/2

Thanks! These will be useful.

ACK, pushed as e7bf95b3ba4ca84b73abffda1abcf6187c5c8a67
I wrote some tests for the file operations as well:
5e76908430bbb56ca981b04a88f12359c73c7e1f


Thanks for adding testcases for these functions.

I plan to do a release (and update the Fedora package) after IPA starts
testing under Python 3. Let me know if an earlier release would help you.
Yes, indeed. It will be very helpful. Let me know if you need any help 
for my side.




Thanks,
Abhijeet Kasurde

--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] [pytest-multihost-devel][PATCH] Functions for handling various file and directory operations

2015-11-25 Thread Petr Viktorin
On 11/25/2015 10:08 AM, Abhijeet Kasurde wrote:
> Hi All,
> 
> Please find the patch for pytest-multihost-plugin.
> 
> Fixes : https://fedorahosted.org/python-pytest-multihost/ticket/2

Thanks! These will be useful.

ACK, pushed as e7bf95b3ba4ca84b73abffda1abcf6187c5c8a67
I wrote some tests for the file operations as well:
5e76908430bbb56ca981b04a88f12359c73c7e1f


I plan to do a release (and update the Fedora package) after IPA starts
testing under Python 3. Let me know if an earlier release would help you.



-- 
Petr Viktorin

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


[Freeipa-devel] [pytest-multihost-devel][PATCH] Functions for handling various file and directory operations

2015-11-25 Thread Abhijeet Kasurde

Hi All,

Please find the patch for pytest-multihost-plugin.

Fixes : https://fedorahosted.org/python-pytest-multihost/ticket/2

Thanks,
Abhijeet Kasurde
From 72dfedf298ed6e27cc10f7c63fa1202a0942c88e Mon Sep 17 00:00:00 2001
From: Abhijeet Kasurde 
Date: Wed, 25 Nov 2015 14:30:35 +0530
Subject: [PATCH] Added functions for handling various file operations

Functions are added for removing directory, removing file,
renaming file.

https://fedorahosted.org/python-pytest-multihost/ticket/2

Signed-off-by: Abhijeet Kasurde 
---
 pytest_multihost/transport.py | 46 ++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/pytest_multihost/transport.py b/pytest_multihost/transport.py
index 2b1ccbc32e8ed4b28e263d9bbe2df4bc2c8617de..f85099fd856e461ca68a342050fae61508c34d10 100644
--- a/pytest_multihost/transport.py
+++ b/pytest_multihost/transport.py
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2013  Red Hat
+# Copyright (C) 2015  Red Hat
 # Copyright (C) 2014  pytest-multihost contributors
 # See COPYING for license
 #
@@ -98,6 +98,18 @@ class Transport(object):
 self._command_index += 1
 return '%s.cmd%s' % (self.host.logger_name, self._command_index)
 
+def rmdir(self, path):
+"""Remove directory"""
+raise NotImplementedError('Transport.rmdir')
+
+def rename_file(self, oldpath, newpath):
+"""Rename file"""
+raise NotImplementedError('Transport.rename_file')
+
+def remove_file(self, filepath):
+"""Removes files"""
+raise NotImplementedError('Transport.remove_file')
+
 
 class Command(object):
 """A Popen-style object representing a remote command
@@ -246,6 +258,18 @@ class ParamikoTransport(Transport):
 self.log.info('PUT %s', remotepath)
 self.sftp.put(localpath, remotepath)
 
+def rmdir(self, path):
+self.log.info('RMDIR %s', path)
+self.sftp.rmdir(path)
+
+def remove_file(self, filepath):
+self.log.info('REMOVE FILE %s', filepath)
+self.sftp.remove(filepath)
+
+def rename_file(self, oldpath, newpath):
+self.log.info('RENAME %s to %s', oldpath, newpath)
+self.sftp.rename(oldpath, newpath)
+
 
 class OpenSSHTransport(Transport):
 """Transport that uses the `ssh` binary"""
@@ -341,6 +365,26 @@ class OpenSSHTransport(Transport):
 else:
 raise IOError('File %r could not be read' % filename)
 
+def rmdir(self, path):
+self.log.info('RMDIR %s', path)
+cmd = self._run(['rmdir', path])
+cmd.wait()
+
+def remove_file(self, filepath):
+self.log.info('REMOVE FILE %s', filepath)
+cmd = self._run(['rm', filepath])
+cmd.wait()
+if cmd.returncode != 0:
+raise IOError('File %r could not be deleted' % filepath)
+
+def rename_file(self, oldpath, newpath):
+self.log.info('RENAME %s TO %s', oldpath, newpath)
+cmd = self._run(['mv', oldpath, newpath])
+cmd.wait()
+if cmd.returncode != 0:
+raise IOError('File %r could not be renamed to %r '
+  % (oldpath, newpath))
+
 
 class SSHCallWrapper(object):
 """Adapts a /usr/bin/ssh call to the paramiko.Channel interface
-- 
2.4.3

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code