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 @@ ...@@ -11,7 +11,7 @@
"""Support code for remote execution and data transfer""" """Support code for remote execution and data transfer"""
from __future__ import generators 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 class ConnectionError(Exception): pass
......
...@@ -16,7 +16,7 @@ remote systems transparent. ...@@ -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 * from static import *
...@@ -75,7 +75,7 @@ class RPathStatic: ...@@ -75,7 +75,7 @@ class RPathStatic:
major, minor = rpin.getdevnums() major, minor = rpin.getdevnums()
rpout.makedev("b", major, minor) rpout.makedev("b", major, minor)
elif rpin.isfifo(): rpout.mkfifo() 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) else: raise RPathException("File %s has unknown type" % rpin.path)
def copy_reg_file(rpin, rpout): def copy_reg_file(rpin, rpout):
...@@ -200,6 +200,11 @@ class RPathStatic: ...@@ -200,6 +200,11 @@ class RPathStatic:
try: return tuple(os.lstat(filename)) try: return tuple(os.lstat(filename))
except os.error: return None 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) MakeStatic(RPathStatic)
...@@ -580,6 +585,12 @@ class RPath(RORPath): ...@@ -580,6 +585,12 @@ class RPath(RORPath):
self.setdata() self.setdata()
assert self.isfifo() 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): def touch(self):
"""Make sure file at self.path exists""" """Make sure file at self.path exists"""
Log("Touching " + self.path, 7) Log("Touching " + self.path, 7)
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"""Support code for remote execution and data transfer""" """Support code for remote execution and data transfer"""
from __future__ import generators 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 class ConnectionError(Exception): pass
......
...@@ -16,7 +16,7 @@ remote systems transparent. ...@@ -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 * from static import *
...@@ -75,7 +75,7 @@ class RPathStatic: ...@@ -75,7 +75,7 @@ class RPathStatic:
major, minor = rpin.getdevnums() major, minor = rpin.getdevnums()
rpout.makedev("b", major, minor) rpout.makedev("b", major, minor)
elif rpin.isfifo(): rpout.mkfifo() 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) else: raise RPathException("File %s has unknown type" % rpin.path)
def copy_reg_file(rpin, rpout): def copy_reg_file(rpin, rpout):
...@@ -200,6 +200,11 @@ class RPathStatic: ...@@ -200,6 +200,11 @@ class RPathStatic:
try: return tuple(os.lstat(filename)) try: return tuple(os.lstat(filename))
except os.error: return None 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) MakeStatic(RPathStatic)
...@@ -580,6 +585,12 @@ class RPath(RORPath): ...@@ -580,6 +585,12 @@ class RPath(RORPath):
self.setdata() self.setdata()
assert self.isfifo() 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): def touch(self):
"""Make sure file at self.path exists""" """Make sure file at self.path exists"""
Log("Touching " + self.path, 7) 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