Changeset 5503f9
- Timestamp:
- 05/09/2013 11:10:02 AM (12 years ago)
- Branches:
- 2.0.x, develop, master
- Children:
- daba92
- Parents:
- d5a385
- git-author:
- bendikro <bendikro@gmail.com> (02/21/2013 12:11:35 AM)
- git-committer:
- Calum Lind <calumlind+deluge@gmail.com> (05/09/2013 11:10:02 AM)
- Location:
- deluge
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
deluge/tests/test_sessionproxy.py
rd5a385 r5503f9 90 90 91 91 def do_get_torrents_status(torrent_ids): 92 inital_keys = [ 93 'queue', 'state', 'name', 'total_wanted', 'progress', 'state', 94 'download_payload_rate', 'upload_payload_rate', 'eta', 'owner' 95 ] 92 inital_keys = ['key1'] 96 93 self.sp.get_torrents_status({'id': torrent_ids}, inital_keys) 97 94 d.addCallback(do_get_torrents_status) -
deluge/ui/sessionproxy.py
rd5a385 r5503f9 100 100 """ 101 101 sd = {} 102 keys = set(keys) 103 keys_len = -1 # The number of keys for the current cache (not the len of keys_diff_cached) 104 keys_diff_cached = [] 105 102 106 for torrent_id in torrent_ids: 103 107 try: 104 108 if keys: 105 sd[torrent_id] = dict([ 106 (x, y) for x, y in self.torrents[torrent_id][1].iteritems() 107 if x in keys 108 ]) 109 sd[torrent_id] = self.torrents[torrent_id][1].copy() 110 111 # Have to remove the keys that weren't requested 112 if len(sd[torrent_id]) == keys_len: 113 # If the number of keys are equal they are the same keys 114 # so we use the cached diff of the keys we need to remove 115 keys_to_remove = keys_diff_cached 116 else: 117 # Not the same keys so create a new diff 118 keys_to_remove = set(sd[torrent_id].iterkeys()) - keys 119 # Update the cached diff 120 keys_diff_cached = keys_to_remove 121 keys_len = len(sd[torrent_id]) 122 123 # Usually there are no keys to remove, so it's cheaper with 124 # this if-test than a for-loop with no iterations. 125 if keys_to_remove: 126 for k in keys_to_remove: 127 del sd[torrent_id][k] 109 128 else: 110 129 sd[torrent_id] = dict(self.torrents[torrent_id][1]) 111 130 except KeyError: 112 131 continue 113 114 132 return sd 115 133 … … 185 203 # Update the internal torrent status dict with the update values 186 204 t = time.time() 187 for key, value in result.ite ms():205 for key, value in result.iteritems(): 188 206 try: 189 207 self.torrents[key][0] = t
Note:
See TracChangeset
for help on using the changeset viewer.