| 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | from annexremote import Master |
| 4 | from annexremote import SpecialRemote |
| 5 | from annexremote import RemoteError |
| 6 | |
| 7 | class MyRemote(SpecialRemote): |
| 8 | def initremote(self): |
| 9 | # initialize the remote, eg. create the folders |
| 10 | # raise RemoteError if the remote couldn't be initialized |
| 11 | |
| 12 | def prepare(self): |
| 13 | # prepare to be used, eg. open TCP connection, authenticate with the server etc. |
| 14 | # raise RemoteError if not ready to use |
| 15 | |
| 16 | def transfer_store(self, key, filename): |
| 17 | # store the file in `filename` to a unique location derived from `key` |
| 18 | # raise RemoteError if the file couldn't be stored |
| 19 | |
| 20 | def transfer_retrieve(self, key, filename): |
| 21 | # get the file identified by `key` and store it to `filename` |
| 22 | # raise RemoteError if the file couldn't be retrieved |
| 23 | |
| 24 | def checkpresent(self, key): |
| 25 | # return True if the key is present in the remote |
| 26 | # return False if the key is not present |
| 27 | # raise RemoteError if the presence of the key couldn't be determined, eg. in case of connection error |
| 28 | |
| 29 | def remove(self, key): |
| 30 | # remove the key from the remote |
| 31 | # raise RemoteError if it couldn't be removed |
| 32 | # note that removing a not existing key isn't considered an error |
| 33 | |
| 34 | def main(): |
| 35 | master = RemoteMaster() |
| 36 | remote = MyRemote(master) |
| 37 | master.LinkRemote(remote) |
| 38 | master.Listen() |
| 39 | |
| 40 | if __name__ == "__main__": |
| 41 | main() |