Commit 2bd216b4 authored by ben's avatar ben

Added socket support


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@169 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent 6d73c406
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment