/usr/share/pyshared/allmydata/util/rrefutil.py is in tahoe-lafs 1.9.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | from foolscap.api import Violation, RemoteException, DeadReferenceError
def add_version_to_remote_reference(rref, default):
"""I try to add a .version attribute to the given RemoteReference. I call
the remote get_version() method to learn its version. I'll add the
default value if the remote side doesn't appear to have a get_version()
method."""
d = rref.callRemote("get_version")
def _got_version(version):
rref.version = version
return rref
def _no_get_version(f):
f.trap(Violation, RemoteException)
rref.version = default
return rref
d.addCallbacks(_got_version, _no_get_version)
return d
def trap_and_discard(f, *errorTypes):
f.trap(*errorTypes)
pass
def trap_deadref(f):
return trap_and_discard(f, DeadReferenceError)
|