| 9 | | |
| 10 | | == aclient == |
| 11 | | The asynchronous api. |
| 12 | | |
| 13 | | Used by rich user interfaces like gtk, or for performance critical batch-calls in webui. |
| 14 | | |
| 15 | | {{{ |
| 16 | | from deluge.ui.client import aclient |
| 17 | | #get list of torrents |
| 18 | | |
| 19 | | class TestClient: |
| 20 | | def __init__(self): |
| 21 | | self.torrent_ids = [] |
| 22 | | self.torrent_status = [] |
| 23 | | |
| 24 | | def cb_session_state(self, torrent_ids): |
| 25 | | self.torrent_ids = torrent_ids |
| 26 | | |
| 27 | | def cb_torrent_status(self, status): |
| 28 | | self.torrent_status.append(status) |
| 29 | | |
| 30 | | def run(self): |
| 31 | | aclient.get_session_state(self.cb_session_state) |
| 32 | | aclient.force_call(block=True) |
| 33 | | print self.torrent_ids |
| 34 | | |
| 35 | | for id in self.torrent_ids: |
| 36 | | aclient.get_torrent_status(self.cb_torrent_status, id , []) |
| 37 | | aclient.force_call(block=True) |
| 38 | | for status in self.torrent_status: |
| 39 | | print status |
| 40 | | |
| 41 | | aclient.set_core_uri() |
| 42 | | t = TestClient() |
| 43 | | t.run() |
| 44 | | }}} |
| | 23 | == aclient == |
| | 24 | The asynchronous api. |
| | 25 | |
| | 26 | Used by rich user interfaces like gtk, or for performance critical batch-calls in webui. |
| | 27 | |
| | 28 | {{{ |
| | 29 | from deluge.ui.client import aclient |
| | 30 | #get list of torrents |
| | 31 | |
| | 32 | class TestClient: |
| | 33 | def __init__(self): |
| | 34 | self.torrent_ids = [] |
| | 35 | self.torrent_status = [] |
| | 36 | |
| | 37 | def cb_session_state(self, torrent_ids): |
| | 38 | self.torrent_ids = torrent_ids |
| | 39 | |
| | 40 | def cb_torrent_status(self, status): |
| | 41 | self.torrent_status.append(status) |
| | 42 | |
| | 43 | def run(self): |
| | 44 | aclient.get_session_state(self.cb_session_state) |
| | 45 | aclient.force_call(block=True) |
| | 46 | print self.torrent_ids |
| | 47 | |
| | 48 | for id in self.torrent_ids: |
| | 49 | aclient.get_torrent_status(self.cb_torrent_status, id , []) |
| | 50 | aclient.force_call(block=True) |
| | 51 | for status in self.torrent_status: |
| | 52 | print status |
| | 53 | |
| | 54 | aclient.set_core_uri() |
| | 55 | t = TestClient() |
| | 56 | t.run() |
| | 57 | }}} |
| | 58 | |