mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-14 13:34:21 +00:00
Cleaned up core.handle_events(self).
This commit is contained in:
parent
8ba55e4dfa
commit
76c8792ce4
45
src/core.py
45
src/core.py
@ -510,45 +510,40 @@ class Manager:
|
||||
# Handle them for the backend's purposes, but still send them up in case the client
|
||||
# wants to do something - show messages, for example
|
||||
def pop_event():
|
||||
try:
|
||||
return deluge_core.pop_event()
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
return deluge_core.pop_event()
|
||||
|
||||
ret = []
|
||||
try:
|
||||
event = deluge_core.pop_event()
|
||||
except:
|
||||
pass
|
||||
return None
|
||||
else:
|
||||
while event is not None:
|
||||
return event
|
||||
|
||||
ret = []
|
||||
while True:
|
||||
event = pop_event()
|
||||
if event is None:
|
||||
break
|
||||
|
||||
print "EVENT: ", event
|
||||
|
||||
ret.append(event)
|
||||
try:
|
||||
if event['unique_ID'] not in self.unique_IDs:
|
||||
event = pop_event()
|
||||
continue
|
||||
except KeyError:
|
||||
event = pop_event()
|
||||
|
||||
if 'unique_ID' in event and \
|
||||
event['unique_ID'] not in self.unique_IDs:
|
||||
continue
|
||||
|
||||
# Call event callbacks
|
||||
# Call plugins events callbacks
|
||||
if event['event_type'] in self.event_callbacks:
|
||||
for plugin_instance in self.event_callbacks[event['event_type']]:
|
||||
plugin_instance.handle_event(event)
|
||||
|
||||
if event['event_type'] is self.constants['EVENT_STORAGE_MOVED']:
|
||||
if event['message'] == "move_failed":
|
||||
raise StorageMoveFailed(_("You cannot move torrent to a different partition. Please fix your preferences"))
|
||||
elif event['message'] == "move_success":
|
||||
self.unique_IDs[event['unique_ID']].save_dir = self.get_pref('default_finished_path')
|
||||
|
||||
|
||||
if event['event_type'] is self.constants['EVENT_FINISHED']:
|
||||
elif event['event_type'] is self.constants['EVENT_FINISHED']:
|
||||
# Queue seeding torrent to bottom if needed
|
||||
if(self.get_pref('enable_move_completed')):
|
||||
if self.get_pref('enable_move_completed'):
|
||||
deluge_core.move_storage(event['unique_ID'], self.get_pref('default_finished_path'))
|
||||
if self.get_pref('queue_seeds_to_bottom'):
|
||||
self.queue_bottom(event['unique_ID'])
|
||||
@ -563,8 +558,7 @@ class Manager:
|
||||
message = event['message']
|
||||
tracker = message[message.find('"')+1:message.rfind('"')]
|
||||
|
||||
self.set_supp_torrent_state_val(unique_ID,
|
||||
"tracker_status",
|
||||
self.set_supp_torrent_state_val(unique_ID, "tracker_status",
|
||||
(tracker, status))
|
||||
|
||||
old_state = self.get_supp_torrent_state(unique_ID)
|
||||
@ -575,12 +569,9 @@ class Manager:
|
||||
|
||||
new[tracker] = message
|
||||
|
||||
self.set_supp_torrent_state_val(unique_ID,
|
||||
"tracker_messages",
|
||||
self.set_supp_torrent_state_val(unique_ID, "tracker_messages",
|
||||
new)
|
||||
|
||||
event = pop_event()
|
||||
|
||||
return ret
|
||||
|
||||
# Filtering functions
|
||||
|
Loading…
x
Reference in New Issue
Block a user