mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-05 18:50:01 +00:00
20 lines
653 B
Python
20 lines
653 B
Python
|
|
from foolscap.api import Violation, RemoteException
|
|
|
|
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
|
|
|