[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[rdiff-backup-users] rdiff-backup with paramiko implementation

From: Paweł Bylina
Subject: [rdiff-backup-users] rdiff-backup with paramiko implementation
Date: Thu, 26 Aug 2010 20:30:19 +0200


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,
full_hostname = remote_cmd
port = 22
username, hostname = full_hostname.split('@')
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'
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:

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 ;-)

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]