Fix #2409 : Console Non-interactive curses ImportError

This commit is contained in:
Calum Lind 2014-01-27 13:02:26 +00:00
commit 188315735b

View file

@ -36,15 +36,15 @@
import logging
import deluge.component as component
import deluge.common
from deluge.common import windows_check
import colors
from deluge.ui.client import client
import curses
import time
log = logging.getLogger(__name__)
class EventLog(component.Component):
"""
Prints out certain events as they are received from the core.
@ -69,7 +69,9 @@ class EventLog(component.Component):
self.previous_time = time.localtime(0)
def on_torrent_added_event(self, torrent_id, from_state):
if from_state: return
if from_state:
return
def on_torrent_status(status):
self.write("{!green!}Torrent Added: {!info!}%s ({!cyan!}%s{!info!})" % (
status["name"], torrent_id)
@ -101,7 +103,8 @@ class EventLog(component.Component):
(state, t_name, torrent_id))
def on_torrent_finished_event(self, torrent_id):
if component.get("AllTorrents").config["ring_bell"]:
if not windows_check() and component.get("AllTorrents").config["ring_bell"]:
import curses.beep
curses.beep()
self.write("{!info!}Torrent Finished: %s ({!cyan!}%s{!info!})" %
(self.console.get_torrent_name(torrent_id), torrent_id))
@ -128,7 +131,7 @@ class EventLog(component.Component):
current_time = time.localtime()
date_different = False
for field in [ "tm_mday", "tm_mon", "tm_year" ]:
for field in ["tm_mday", "tm_mon", "tm_year"]:
c = getattr(current_time, field)
p = getattr(self.previous_time, field)
if c != p: