SearchFAQMemberlist Log in
Reply to topic Page 1 of 1
rdiff-backup with paramiko implementation
Author Message
Post rdiff-backup with paramiko implementation 
Hi,

i've implemented paramiko library to rdiff-backup code. If someone is interested in I changed only two files: SetConnections.py and Main.py.

Here is some code:


# SetConnections.py modifications
import paramiko
import new

__cmd_schema = '%s'
# ......
# init_connection() function
# Remove .__del__ method from BufferedFile. This can broke thread # and print some nasty exceptions at the end of rdiff-backup
# working. paramiko.file.BufferedFile.__del__ = new.instancemethod( lambda x: None, None, paramiko.file.BufferedFile ) full_hostname = remote_cmd port = 22
username, hostname = full_hostname.split(' < at > ') if hostname.find(':') > 0: hostname, port = hostname.split(':') trans = paramiko.Transport((hostname, int(port)))
trans.connect(username=username, password='yourpassword') chan = trans.open_channel("session") command = 'rdiff-backup --server' chan.exec_command(command) stdin = chan.makefile('w')
stdout = chan.makefile() conn_number = len(Globals.connections) conn = connection.PipeConnection(stdout, stdin, conn_number)
Paramiko channel have makefile() function wich is simulating pipe similar to popen2(). The second modification is some cleanup code for paramiko threads:

# Main.py
# cleanup() function

# join paramiko threads from paramiko.transport import _active_threads for tobj in _active_threads: tobj.stop_thread() tobj.join()


And this is all. I've tested it on Windows and Linux and it's working fine. Paramiko is a little slower than ssh client on LInux.

Now i want to make some more modifications in code (for example reading login/password from config file and GUI) so publishing paramiko connection code now is a good idea Wink

Modified files u can find here: http://pako.overflow.pl/trash/rdiff-backup/

Cheers!

Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  


Magic SEO URL for phpBB