source: trunk/src/allmydata/util/rrefutil.py

Last change on this file was 1cfe843d, checked in by Alexandre Detiste <alexandre.detiste@…>, at 2024-02-22T23:40:25Z

more python2 removal

  • Property mode set to 100644
File size: 681 bytes
Line 
1"""
2Ported to Python 3.
3"""
4
5from foolscap.api import Violation, RemoteException
6
7
8def add_version_to_remote_reference(rref, default):
9    """I try to add a .version attribute to the given RemoteReference. I call
10    the remote get_version() method to learn its version. I'll add the
11    default value if the remote side doesn't appear to have a get_version()
12    method."""
13    d = rref.callRemote("get_version")
14    def _got_version(version):
15        rref.version = version
16        return rref
17    def _no_get_version(f):
18        f.trap(Violation, RemoteException)
19        rref.version = default
20        return rref
21    d.addCallbacks(_got_version, _no_get_version)
22    return d
Note: See TracBrowser for help on using the repository browser.