From 7b7cfcdf6534883314fa50d28c03b87ffb214b49 Mon Sep 17 00:00:00 2001 From: ben Date: Fri, 19 Jul 2002 07:25:00 +0000 Subject: Added socket support git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@169 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/rdiff_backup/connection.py | 2 +- rdiff-backup/rdiff_backup/rpath.py | 15 +++++++++++++-- rdiff-backup/src/connection.py | 2 +- rdiff-backup/src/rpath.py | 15 +++++++++++++-- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/rdiff-backup/rdiff_backup/connection.py b/rdiff-backup/rdiff_backup/connection.py index 20dd3db..1506675 100644 --- a/rdiff-backup/rdiff_backup/connection.py +++ b/rdiff-backup/rdiff_backup/connection.py @@ -11,7 +11,7 @@ """Support code for remote execution and data transfer""" from __future__ import generators -import types, os, tempfile, cPickle, shutil, traceback, pickle +import types, os, tempfile, cPickle, shutil, traceback, pickle, socket class ConnectionError(Exception): pass diff --git a/rdiff-backup/rdiff_backup/rpath.py b/rdiff-backup/rdiff_backup/rpath.py index 22e901e..6f9734f 100644 --- a/rdiff-backup/rdiff_backup/rpath.py +++ b/rdiff-backup/rdiff_backup/rpath.py @@ -16,7 +16,7 @@ remote systems transparent. """ -import os, stat, re, sys, shutil, gzip +import os, stat, re, sys, shutil, gzip, socket from static import * @@ -75,7 +75,7 @@ class RPathStatic: major, minor = rpin.getdevnums() rpout.makedev("b", major, minor) elif rpin.isfifo(): rpout.mkfifo() - elif rpin.issock(): Log("Found socket, ignoring", 1) + elif rpin.issock(): rpout.mksock() else: raise RPathException("File %s has unknown type" % rpin.path) def copy_reg_file(rpin, rpout): @@ -200,6 +200,11 @@ class RPathStatic: try: return tuple(os.lstat(filename)) except os.error: return None + def make_socket(path): + """Make a local socket at the given path""" + s = socket.socket(socket.AF_UNIX) + s.bind(path) + MakeStatic(RPathStatic) @@ -580,6 +585,12 @@ class RPath(RORPath): self.setdata() assert self.isfifo() + def mksock(self): + """Make a socket at self.path""" + self.conn.RPathStatic.make_socket(self.path) + self.setdata() + assert self.issock() + def touch(self): """Make sure file at self.path exists""" Log("Touching " + self.path, 7) diff --git a/rdiff-backup/src/connection.py b/rdiff-backup/src/connection.py index 20dd3db..1506675 100644 --- a/rdiff-backup/src/connection.py +++ b/rdiff-backup/src/connection.py @@ -11,7 +11,7 @@ """Support code for remote execution and data transfer""" from __future__ import generators -import types, os, tempfile, cPickle, shutil, traceback, pickle +import types, os, tempfile, cPickle, shutil, traceback, pickle, socket class ConnectionError(Exception): pass diff --git a/rdiff-backup/src/rpath.py b/rdiff-backup/src/rpath.py index 22e901e..6f9734f 100644 --- a/rdiff-backup/src/rpath.py +++ b/rdiff-backup/src/rpath.py @@ -16,7 +16,7 @@ remote systems transparent. """ -import os, stat, re, sys, shutil, gzip +import os, stat, re, sys, shutil, gzip, socket from static import * @@ -75,7 +75,7 @@ class RPathStatic: major, minor = rpin.getdevnums() rpout.makedev("b", major, minor) elif rpin.isfifo(): rpout.mkfifo() - elif rpin.issock(): Log("Found socket, ignoring", 1) + elif rpin.issock(): rpout.mksock() else: raise RPathException("File %s has unknown type" % rpin.path) def copy_reg_file(rpin, rpout): @@ -200,6 +200,11 @@ class RPathStatic: try: return tuple(os.lstat(filename)) except os.error: return None + def make_socket(path): + """Make a local socket at the given path""" + s = socket.socket(socket.AF_UNIX) + s.bind(path) + MakeStatic(RPathStatic) @@ -580,6 +585,12 @@ class RPath(RORPath): self.setdata() assert self.isfifo() + def mksock(self): + """Make a socket at self.path""" + self.conn.RPathStatic.make_socket(self.path) + self.setdata() + assert self.issock() + def touch(self): """Make sure file at self.path exists""" Log("Touching " + self.path, 7) -- cgit v1.2.1