From bb0746c3e8b657d85492be84cffd09f3a57ae3df Mon Sep 17 00:00:00 2001 From: Nick Lanham Date: Wed, 13 Apr 2011 11:52:03 +0200 Subject: [PATCH 1/3] use os.sep and strip what's already in input box from complete options --- deluge/ui/console/modes/input_popup.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/deluge/ui/console/modes/input_popup.py b/deluge/ui/console/modes/input_popup.py index 8c52f11a6..ed00f2140 100644 --- a/deluge/ui/console/modes/input_popup.py +++ b/deluge/ui/console/modes/input_popup.py @@ -42,7 +42,7 @@ try: except ImportError: pass -import logging,os.path +import logging,os,os.path from popup import Popup @@ -476,7 +476,8 @@ class TextInput(InputField): self.cursor = len(prefix) if len(opts) > 1 and second_hit: # display multiple options on second tab hit - self.opts = " ".join(opts) + sp = self.value.rfind(os.sep)+1 + self.opts = " ".join([o[sp:] for o in opts]) # Cursor movement elif c == curses.KEY_LEFT: @@ -519,6 +520,7 @@ class TextInput(InputField): self.value = self.value[:self.cursor] + uchar + self.value[self.cursor:] # Move the cursor forward self.cursor+=1 + def complete(self,line): line = os.path.abspath(os.path.expanduser(line)) @@ -534,7 +536,7 @@ class TextInput(InputField): continue f = os.path.join(line, f) if os.path.isdir(f): - f += "/" + f += os.sep ret.append(f) else: # This is a file, but we could be looking for another file that @@ -552,9 +554,8 @@ class TextInput(InputField): p = os.path.join(os.path.dirname(line), f) if os.path.isdir(p): - p += "/" + p += os.sep ret.append(p) - return ret From 42e1e2fd20f014d9c5d7b756210718d35182d623 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 13 Apr 2011 12:54:59 +0100 Subject: [PATCH 2/3] Include proper Date header in email notifications. --- deluge/plugins/notifications/notifications/core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/deluge/plugins/notifications/notifications/core.py b/deluge/plugins/notifications/notifications/core.py index 2139de257..92c61461d 100644 --- a/deluge/plugins/notifications/notifications/core.py +++ b/deluge/plugins/notifications/notifications/core.py @@ -38,6 +38,7 @@ # import smtplib +from datetime import datetime from twisted.internet import defer, threads from deluge import component from deluge.event import known_events @@ -118,11 +119,13 @@ class CoreNotifications(CustomNotifications): From: %(smtp_from)s To: %(smtp_recipients)s Subject: %(subject)s +Date: %(date)s """ % {'smtp_from': self.config['smtp_from'], 'subject': subject, - 'smtp_recipients': to_addrs} + 'smtp_recipients': to_addrs, + 'date': datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S +0000').strip()} message = '\r\n'.join((headers + message).splitlines()) From 5bc304470c8dfc8cccaeaefb17271d84ab2bb47f Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 14 Apr 2011 09:29:40 +0100 Subject: [PATCH 3/3] Let's use what the stdlib provides us. Use `email.utils.formatdate` instead of `strftime()` a `datetime` object. --- deluge/plugins/notifications/notifications/core.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/deluge/plugins/notifications/notifications/core.py b/deluge/plugins/notifications/notifications/core.py index 92c61461d..29cb6c3c9 100644 --- a/deluge/plugins/notifications/notifications/core.py +++ b/deluge/plugins/notifications/notifications/core.py @@ -38,7 +38,7 @@ # import smtplib -from datetime import datetime +from email.utils import formatdate from twisted.internet import defer, threads from deluge import component from deluge.event import known_events @@ -125,7 +125,8 @@ Date: %(date)s """ % {'smtp_from': self.config['smtp_from'], 'subject': subject, 'smtp_recipients': to_addrs, - 'date': datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S +0000').strip()} + 'date': formatdate() + } message = '\r\n'.join((headers + message).splitlines())