[-]
[+]
|
Changed |
getmail.changes
|
|
[-]
[+]
|
Changed |
getmail.spec
^
|
|
[-]
[+]
|
Changed |
getmail-4.39.1.tar.bz2/PKG-INFO
^
|
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: getmail
-Version: 4.34.0
+Version: 4.39.1
Summary: a mail retrieval, sorting, and delivering system
Home-page: http://pyropus.ca/software/getmail/
Author: Charles Cazabon
|
[-]
[+]
|
Changed |
getmail-4.39.1.tar.bz2/docs/CHANGELOG
^
|
@@ -1,3 +1,42 @@
+Version 4.39.1
+10 March 2013
+ -fix a bug that could crop up when retrieving mail via IMAP from Gmail, and
+ the Gmail servers provided weird data in their header extensions.
+ Thanks: Krzysztof Warzecha.
+
+Version 4.39.0
+22 February 2013
+ -fix an oldmail filename issue that occurred with certain non-ASCII
+ characters in an IMAP mailbox name. Thanks: Michael Kockmeyer.
+
+Version 4.38.0
+16 February 2013
+ -fix retrieving mail from an IMAP mailbox with non-ASCII characters in its
+ name causing difficult-to-understand unicode errors during delivery.
+ Thanks: "fsLeg", Krzysztof Warzecha.
+
+Version 4.37.0
+27 January 2013
+ -handle IMAP servers which include "/" in message IDs better, so those
+ messages aren't always thought to be new. Thanks: Bradley Rintoul.
+ -record (IMAP) mailbox retrieved from in X-getmail-retrieved-from-mailbox:
+ header field, and make it available as %(mailbox) substitution in
+ MDA_external arguments. Thanks: Les Barstow.
+ -add delete_bigger_than option to allow removal of large messages after
+ retrieval, even if not deleting messages otherwise. Thanks: Jan Vereecke.
+
+Version 4.36.0
+15 December 2012
+ -add support for retrieving POP/IMAP passwords from, and storing them to,
+ the Gnome keyring. Thanks: Krzysztof Warzecha, Scott Hepler.
+
+Version 4.35.0
+24 October 2012
+ -fix From_ quoting in mbox delivery; use of the Python stdlib function
+ meant getmail was incorrectly using mboxo-style quoting instead of
+ mboxrd quoting, probably since early in the v4 series.
+ Thanks: Christoph Mitterer.
+
Version 4.34.0
8 September 2012
-retrieve Gmail metadata (labels, thread ID, message ID) via IMAP extension
|
[-]
[+]
|
Changed |
getmail-4.39.1.tar.bz2/docs/configuration.html
^
|
@@ -546,8 +546,22 @@
password
(<a href="#parameter-string">string</a>)
— password to use when logging in to the mail server. If not
- provided (and not using Kerberos authentication -- see below), getmail
- will prompt you to enter the password when getmail is run.
+ using Kerberos authentication -- see below -- getmail gets the password
+ credential for the POP/IMAP server in one of the following ways:
+ <ol>
+ <li>from the <span class="file">password</span> configuration item in the getmailrc file</li>
+ <li>on Mac OS X only, from the OS X keychain</li>
+ <li>on systems with Gnome keyring support, from the default Gnome keyring</li>
+ <li>if not found via any of the above methods, getmail will prompt for the password when run</li>
+ </ol>
+ To store your POP/IMAP account password into the Gnome keyring, ensure
+ the password is not provided in the getmailrc file, and run getmail with
+ the special option <span class="file">--store-password-in-gnome-keyring</span>;
+ getmail will run, prompt you for the password, store it in the Gnome
+ keyring, and exit without retrieving mail. If this option is not
+ recognized, your Python installation does not have Gnome keyring
+ integration support, or Gnome indicates that the keyring is not
+ available.
</li>
</ul>
<p>
@@ -1344,6 +1358,11 @@
<span class="sample">%(domain)</span>
— domain-part of the envelope recipient address
</li>
+ <li>
+ <span class="sample">%(mailbox)</span>
+ — the IMAP mailbox name the message was retrieved from;
+ for POP, this will be empty
+ </li>
</ul>
The default value of the
<span class="file">arguments</span>
@@ -2094,6 +2113,23 @@
Default: 0, which means not to enable this feature.
</li>
<li>
+ delete_bigger_than
+ (<a href="#parameter-integer">integer</a>)
+ — if set, getmail will delete messages larger than this number of
+ bytes after retrieving them, even if the
+ <span class="file">delete</span>
+ and <span class="file">delete_after</span>
+ options are disabled. The purpose of this feature is to allow deleting
+ only large messages, to help keep a mailbox under quota.
+ Has no effect if <span class="file">delete</span> is set, as that will
+ unconditionally remove messages. If
+ <span class="file">delete_after</span> is also set, the message will be
+ deleted immediately after retrieval if it is over this size, and
+ otherwise will be deleted according to the setting of
+ <span class="file">delete_after</span>.
+ Default: 0, which means not to enable this feature.
+ </li>
+ <li>
max_bytes_per_session
(<a href="#parameter-integer">integer</a>)
— if set, getmail will retrieve messages totalling up to this
|
[-]
[+]
|
Changed |
getmail-4.39.1.tar.bz2/docs/configuration.txt
^
|
@@ -262,9 +262,24 @@
the default is a port appropriate for the protocol (110 for POP3,
etc.)
* password (string) -- password to use when logging in to the mail
- server. If not provided (and not using Kerberos authentication -- see
- below), getmail will prompt you to enter the password when getmail is
- run.
+ server. If not using Kerberos authentication -- see below -- getmail
+ gets the password credential for the POP/IMAP server in one of the
+ following ways:
+
+ 1. from the password configuration item in the getmailrc file
+ 2. on Mac OS X only, from the OS X keychain
+ 3. on systems with Gnome keyring support, from the default Gnome
+ keyring
+ 4. if not found via any of the above methods, getmail will prompt
+ for the password when run
+
+ To store your POP/IMAP account password into the Gnome keyring, ensure
+ the password is not provided in the getmailrc file, and run getmail
+ with the special option --store-password-in-gnome-keyring; getmail
+ will run, prompt you for the password, store it in the Gnome keyring,
+ and exit without retrieving mail. If this option is not recognized,
+ your Python installation does not have Gnome keyring integration
+ support, or Gnome indicates that the keyring is not available.
All IMAP retriever types also take the following optional parameters:
@@ -658,6 +673,8 @@
* %(recipient) -- envelope recipient address
* %(local) -- local-part of the envelope recipient address
* %(domain) -- domain-part of the envelope recipient address
+ * %(mailbox) -- the IMAP mailbox name the message was retrieved
+ from; for POP, this will be empty
The default value of the arguments parameter is (), so no arguments
are supplied to the command.
@@ -1096,6 +1113,15 @@
delete parameter has higher priority; if both are set, the messages
will be deleted immediately. Default: 0, which means not to enable
this feature.
+ * delete_bigger_than (integer) -- if set, getmail will delete messages
+ larger than this number of bytes after retrieving them, even if the
+ delete and delete_after options are disabled. The purpose of this
+ feature is to allow deleting only large messages, to help keep a
+ mailbox under quota. Has no effect if delete is set, as that will
+ unconditionally remove messages. If delete_after is also set, the
+ message will be deleted immediately after retrieval if it is over this
+ size, and otherwise will be deleted according to the setting of
+ delete_after. Default: 0, which means not to enable this feature.
* max_bytes_per_session (integer) -- if set, getmail will retrieve
messages totalling up to this number of bytes before closing the
session with the server. This can be useful if you do not want large
|
[-]
[+]
|
Changed |
getmail-4.39.1.tar.bz2/getmail
^
|
@@ -15,6 +15,17 @@
from optparse import OptionParser, OptionGroup
import socket
+# Optional gnome-keyring integration
+try:
+ import gnomekeyring
+ import glib
+ glib.set_application_name('getmail')
+ # And test to see if it's actually available
+ if not gnomekeyring.is_available():
+ gnomekeyring = None
+except ImportError:
+ gnomekeyring = None
+
options_bool = (
'read_all',
'delete',
@@ -25,6 +36,7 @@
)
options_int = (
'delete_after',
+ 'delete_bigger_than',
'max_message_size',
'max_messages_per_session',
'max_bytes_per_session',
@@ -45,7 +57,7 @@
logging
from getmailcore.exceptions import *
from getmailcore.utilities import eval_bool, logfile, format_params, \
- address_no_brackets, expand_user_vars
+ address_no_brackets, expand_user_vars, get_password
except ImportError, o:
sys.stderr.write('ImportError: %s\n' % o)
sys.exit(127)
@@ -62,6 +74,7 @@
'read_all' : True,
'delete' : False,
'delete_after' : 0,
+ 'delete_bigger_than' : 0,
'max_message_size' : 0,
'max_messages_per_session' : 0,
'max_bytes_per_session' : 0,
@@ -215,6 +228,12 @@
if options['delete'] and timestamp:
log.debug(' will delete\n')
delete = True
+
+ if (options['delete_bigger_than']
+ and size > options['delete_bigger_than']):
+ log.debug(' bigger than %d, will delete\n'
+ % options['delete_bigger_than'])
+ delete = True
if not retrieve and timestamp is None:
# We haven't retrieved this message. Don't delete it.
@@ -381,6 +400,12 @@
dest='trace', action='store_true', default=False,
help='print extended trace information (extremely verbose)'
)
+ if gnomekeyring:
+ parser.add_option(
+ '--store-password-in-gnome-keyring',
+ dest='store_gnome_keyring', action='store_true', default=False,
+ help='store the POP/IMAP password in the Gnome keyring'
+ )
overrides = OptionGroup(
parser, 'Overrides',
'The following options override those specified in any '
@@ -478,6 +503,7 @@
'read_all' : defaults['read_all'],
'delete' : defaults['delete'],
'delete_after' : defaults['delete_after'],
+ 'delete_bigger_than' : defaults['delete_bigger_than'],
'max_message_size' : defaults['max_message_size'],
'max_messages_per_session' :
defaults['max_messages_per_session'],
@@ -600,6 +626,30 @@
except getmailOperationError, o:
log.error('Error initializing retriever: %s\n' % o)
continue
+
+ # Retriever is okay. Check if user wants us to store the
+ # password in a Gnome keyring for future use.
+ if gnomekeyring and options.store_gnome_keyring:
+ # Need to get the password first, if the user hasn't put
+ # it in the rc file.
+ if retriever.conf.get('password', None) is None:
+ password = get_password(
+ str(retriever), retriever.conf['username'],
+ retriever.conf['server'], retriever.received_with,
+ log
+ )
+ else:
+ password = retriever.conf['password']
+
+ gnomekeyring.set_network_password_sync(
+ # keyring=None, user, domain=None, server, object=None,
+ # protocol, authtype=None, port=0
+ None, retriever.conf['username'], None,
+ retriever.conf['server'], None, retriever.received_with,
+ None, 0, password
+ )
+ log.info('Stored password in Gnome keyring. Exiting.\n')
+ raise SystemExit()
# Destination
log.debug(' getting destination\n')
|
[-]
[+]
|
Changed |
getmail-4.39.1.tar.bz2/getmail.spec
^
|
@@ -2,7 +2,7 @@
Summary: POP3 mail retriever with reliable Maildir delivery
Name: getmail
-Version: 4.34.0
+Version: 4.39.1
Release: 1
License: GPL
Group: Applications/Internet
@@ -52,6 +52,36 @@
%{python_sitelib}/getmailcore/
%changelog
+* Sun Mar 10 2013 Charles Cazabon <charlesc-getmail-rpm@pyropus.ca>
+-update to version 4.39.1
+
+* Fri Feb 22 2013 Charles Cazabon <charlesc-getmail-rpm@pyropus.ca>
+-update to version 4.39.0
+
+* Fri Feb 22 2013 Charles Cazabon <charlesc-getmail-rpm@pyropus.ca>
+-update to version 4.39.0
+
+* Fri Feb 22 2013 Charles Cazabon <charlesc-getmail-rpm@pyropus.ca>
+-update to version 4.39.0
+
+* Sat Feb 16 2013 Charles Cazabon <charlesc-getmail-rpm@pyropus.ca>
+-update to version 4.38.0
+
+* Sat Feb 16 2013 Charles Cazabon <charlesc-getmail-rpm@pyropus.ca>
+-update to version 4.38.0
+
+* Sun Jan 27 2013 Charles Cazabon <charlesc-getmail-rpm@pyropus.ca>
+-update to version 4.37.0
+
+* Sun Jan 27 2013 Charles Cazabon <charlesc-getmail-rpm@pyropus.ca>
+-update to version 4.37.0
+
+* Sat Dec 15 2012 Charles Cazabon <charlesc-getmail-rpm@pyropus.ca>
+-update to version 4.36.0
+
+* Wed Oct 24 2012 Charles Cazabon <charlesc-getmail-rpm@pyropus.ca>
+-update to version 4.35.0
+
* Sat Sep 08 2012 Charles Cazabon <charlesc-getmail-rpm@pyropus.ca>
-update to version 4.34.0
|
[-]
[+]
|
Changed |
getmail-4.39.1.tar.bz2/getmailcore/__init__.py
^
|
@@ -16,7 +16,7 @@
raise ImportError('getmail version 4 requires Python version 2.3.3'
' or later')
-__version__ = '4.34.0'
+__version__ = '4.39.1'
__all__ = [
'baseclasses',
|
[-]
[+]
|
Changed |
getmail-4.39.1.tar.bz2/getmailcore/_retrieverbases.py
^
|
@@ -433,15 +433,16 @@
or (isinstance(mailbox, (str, unicode)) and mailbox)), (
'bad mailbox %s (%s)' % (mailbox, type(mailbox))
)
- if isinstance(mailbox, str):
- mailbox = mailbox.decode('utf-8')
filename = self.oldmail_filename
- if mailbox is None:
- # No mailbox (POP), use above with no extension
- pass
- else:
+ if mailbox is not None:
+ if isinstance(mailbox, str):
+ mailbox = mailbox.decode('utf-8')
+ mailbox = re.sub(STRIP_CHAR_RE, '.', mailbox)
+ mailbox = mailbox.encode('utf-8')
# Use oldmail file per IMAP folder
- filename += '-' + re.sub(STRIP_CHAR_RE, '.', mailbox)
+ filename += '-' + mailbox
+ # else:
+ # mailbox is None, is POP, just use filename
return filename
def oldmail_exists(self, mailbox):
@@ -629,6 +630,10 @@
for (i, line) in enumerate(msglist):
try:
(msgnum, msgid) = line.split(None, 1)
+ # Don't allow / in UIDs we store, as we look for that to
+ # detect old-style oldmail files. Shouldn't occur in POP3
+ # anyway.
+ msgid = msgid.replace('/', '-')
except ValueError:
# Line didn't contain two tokens. Server is broken.
raise getmailOperationError(
@@ -724,8 +729,8 @@
# Handle password
if self.conf.get('password', None) is None:
self.conf['password'] = get_password(
- self, self.conf['username'], self.conf['server'], 'pop3',
- self.log
+ self, self.conf['username'], self.conf['server'],
+ self.received_with, self.log
)
RetrieverSkeleton.initialize(self, options)
try:
@@ -1015,7 +1020,8 @@
self.log.debug('selecting mailbox "%s"' % mailbox + os.linesep)
try:
- if self.app_options['delete'] or self.app_options['delete_after']:
+ if (self.app_options['delete'] or self.app_options['delete_after']
+ or self.app_options['delete_bigger_than']):
read_only = False
else:
read_only = True
@@ -1055,9 +1061,11 @@
)
for line in response:
r = self._parse_imapattrresponse(line)
- msgid = (
- '%s/%s' % (self.uidvalidity, r['uid'])
- )
+ # Don't allow / in UIDs we store, as we look for that to
+ # detect old-style oldmail files. Can occur with IMAP, at
+ # least with some servers.
+ uid = r['uid'].replace('/', '-')
+ msgid = '%s/%s' % (self.uidvalidity, uid)
self._mboxuids[msgid] = r['uid']
self._mboxuidorder.append(msgid)
self.msgnum_by_msgid[msgid] = None
@@ -1145,6 +1153,10 @@
raise getmailRetrievalError('failed to retrieve msgid %s'
% msgid)
+ # record mailbox retrieved from in a header
+ msg.add_header('X-getmail-retrieved-from-mailbox',
+ self.mailbox_selected)
+
# google extensions: apply labels, etc
if 'X-GM-EXT-1' in self.conn.capabilities:
metadata = self._getgmailmetadata(uid, msg)
@@ -1186,7 +1198,7 @@
'Could not parse google imap extensions. Server said: %s'
% repr(response)
)
- return ()
+ return {}
results = ext.groupdict()
metadata = {}
@@ -1219,8 +1231,8 @@
if (self.conf.get('password', None) is None
and not (HAVE_KERBEROS_GSS and self.conf['use_kerberos'])):
self.conf['password'] = get_password(
- self, self.conf['username'], self.conf['server'], 'imap',
- self.log
+ self, self.conf['username'], self.conf['server'],
+ self.received_with, self.log
)
RetrieverSkeleton.initialize(self, options)
|
[-]
[+]
|
Changed |
getmail-4.39.1.tar.bz2/getmailcore/destinations.py
^
|
@@ -81,6 +81,7 @@
self.received_from = None
self.received_with = None
self.received_by = None
+ self.retriever = None
self.log.trace('done\n')
def retriever_info(self, retriever):
@@ -88,6 +89,7 @@
self.received_from = retriever.received_from
self.received_with = retriever.received_with
self.received_by = retriever.received_by
+ self.retriever = retriever
def deliver_message(self, msg, delivered_to=True, received=True):
self.log.trace()
@@ -608,6 +610,9 @@
%(recipient) - recipient address
%(domain) - domain-part of recipient address
%(local) - local-part of recipient address
+ %(mailbox) - for IMAP retrievers, the name of the
+ server-side mailbox/folder the message was retrieved
+ from. Will be empty for POP.
Warning: the text of these replacements is taken from the
message and is therefore under the control of a potential
@@ -691,6 +696,7 @@
'or GID 0 by default'
)
args = [self.conf['path'], self.conf['path']]
+ msginfo['mailbox'] = self.retriever.mailbox_selected or ''
for arg in self.conf['arguments']:
arg = expand_user_vars(arg)
for (key, value) in msginfo.items():
|
[-]
[+]
|
Changed |
getmail-4.39.1.tar.bz2/getmailcore/message.py
^
|
@@ -10,10 +10,12 @@
import os
import time
import cStringIO
+import re
import email
import email.Errors
import email.Utils
import email.Parser
+import email.header
from email.Generator import Generator
from getmailcore.exceptions import *
@@ -29,6 +31,9 @@
'recipient'
)
+RE_FROMLINE = re.compile(r'^(>*From )', re.MULTILINE)
+
+
#######################################
def corrupt_message(why, fromlines=None, fromstring=None):
log = getmailcore.logging.Logger()
@@ -130,19 +135,25 @@
it by writing out what we need, letting the generator write out the
message, splitting it into lines, and joining them with the platform
EOL.
+
+ Note on mangle_from: the Python email.Generator class apparently only
+ quotes "From ", not ">From " (i.e. it uses mboxo format instead of
+ mboxrd). So we don't use its mangling, and do it by hand instead.
'''
- f = cStringIO.StringIO()
if include_from:
- # This needs to be written out first, so we can't rely on the
- # generator
- f.write('From %s %s' % (mbox_from_escape(self.sender),
- time.asctime()) + os.linesep)
+ # Mbox-style From line, not rfc822 From: header field.
+ fromline = 'From %s %s' % (mbox_from_escape(self.sender),
+ time.asctime()) + os.linesep
+ else:
+ fromline = ''
# Write the Return-Path: header
- f.write(format_header('Return-Path', '<%s>' % self.sender))
+ rpline = format_header('Return-Path', '<%s>' % self.sender)
# Remove previous Return-Path: header fields.
del self.__msg['Return-Path']
if delivered_to:
- f.write(format_header('Delivered-To', self.recipient or 'unknown'))
+ dtline = format_header('Delivered-To', self.recipient or 'unknown')
+ else:
+ dtline = ''
if received:
content = 'from %s by %s with %s' % (
self.received_from, self.received_by, self.received_with
@@ -151,13 +162,20 @@
content += ' for <%s>' % self.recipient
content += '; ' + time.strftime('%d %b %Y %H:%M:%S -0000',
time.gmtime())
- f.write(format_header('Received', content))
- gen = Generator(f, mangle_from, 0)
+ receivedline = format_header('Received', content)
+ else:
+ receivedline = ''
# From_ handled above, always tell the generator not to include it
try:
+ tmpf = cStringIO.StringIO()
+ gen = Generator(tmpf, False, 0)
gen.flatten(self.__msg, False)
- f.seek(0)
- return os.linesep.join(f.read().splitlines() + [''])
+ strmsg = tmpf.getvalue()
+ if mangle_from:
+ # do mboxrd-style "From " line quoting
+ strmsg = RE_FROMLINE.sub(r'>\1', strmsg)
+ return (fromline + rpline + dtline + receivedline
+ + os.linesep.join(strmsg.splitlines() + ['']))
except TypeError, o:
# email module chokes on some badly-misformatted messages, even
# late during flatten(). Hope this is fixed in Python 2.4.
@@ -171,7 +189,7 @@
include_from)
def add_header(self, name, content):
- self.__msg[name] = content.rstrip()
+ self.__msg[name] = email.header.Header(content.rstrip())
def remove_header(self, name):
del self.__msg[name]
|
[-]
[+]
|
Changed |
getmail-4.39.1.tar.bz2/getmailcore/utilities.py
^
|
@@ -38,6 +38,15 @@
import getpass
import commands
+# Optional gnome-keyring integration
+try:
+ import gnomekeyring
+ # And test to see if it's actually available
+ if not gnomekeyring.is_available():
+ gnomekeyring = None
+except ImportError:
+ gnomekeyring = None
+
from getmailcore.exceptions import *
logtimeformat = '%Y-%m-%d %H:%M:%S'
@@ -477,41 +486,79 @@
#######################################
-if os.name == 'posix' and os.path.isfile(osx_keychain_binary):
- def keychain_password(user, server, protocol, logger):
- """Mac OSX: return a keychain password, if it exists. Otherwise, return
- None.
- """
- # wish we could pass along a comment to this thing for the user prompt
- cmd = "%s find-internet-password -g -a '%s' -s '%s' -r '%s'" % (
- osx_keychain_binary, user, server, protocol
- )
- (status, output) = commands.getstatusoutput(cmd)
- if status != os.EX_OK or not output:
- logger.error('keychain command %s failed: %s %s'
- % (cmd, status, output))
+keychain_password = None
+if os.name == 'posix':
+ if os.path.isfile(osx_keychain_binary):
+ def keychain_password(user, server, protocol, logger):
+ """Mac OSX: return a keychain password, if it exists. Otherwise, return
+
+ None.
+ """
+ # wish we could pass along a comment to this thing for the user prompt
+ cmd = "%s find-internet-password -g -a '%s' -s '%s' -r '%s'" % (
+ osx_keychain_binary, user, server, protocol
+ )
+ (status, output) = commands.getstatusoutput(cmd)
+ if status != os.EX_OK or not output:
+ logger.error('keychain command %s failed: %s %s'
+ % (cmd, status, output))
+ return None
+ password = None
+ for line in output.split('\n'):
+ match = re.match(r'password: "([^"]+)"', line)
+ if match:
+ password = match.group(1)
+ if password is None:
+ logger.debug('No keychain password found for %s %s %s'
+ % (user, server, protocol))
+ return password
+ elif gnomekeyring:
+ def keychain_password(user, server, protocol, logger):
+ """Gnome: return a keyring password, if it exists. Otherwise, return
+ None.
+ """
+ #logger.trace('trying Gnome keyring for user="%s", server="%s", protocol="%s"\n'
+ # % (user, server, protocol))
+ try:
+ # http://developer.gnome.org/gnome-keyring/3.5/gnome-keyring
+ # -Network-Passwords.html#gnome-keyring-find-network-password-sync
+ secret = gnomekeyring.find_network_password_sync(
+ # user, domain=None, server, object=None, protocol,
+ # authtype=None, port=0
+ user, None, server, None, protocol, None, 0
+ )
+
+ #logger.trace('got keyring result %s' % str(secret))
+ except gnomekeyring.NoMatchError:
+ logger.debug('gnome-keyring does not know password for %s %s %s'
+ % (user, server, protocol))
+ return None
+
+ # secret looks like this:
+ # [{'protocol': 'imap', 'keyring': 'Default', 'server': 'gmail.com',
+ # 'user': 'hiciu', 'item_id': 1L, 'password': 'kielbasa'}]
+ if secret and 'password' in secret[0]:
+ return secret[0]['password']
+
return None
- password = None
- for line in output.split('\n'):
- match = re.match(r'password: "([^"]+)"', line)
- if match:
- password = match.group(1)
- if password is None:
- logger.debug('No keychain password found for %s %s %s'
- % (user, server, protocol))
- return password
-else:
+ #else:
+ # Posix but no OSX keychain or Gnome keyring.
+ # Fallthrough
+if keychain_password is None:
def keychain_password(user, server, protocol, logger):
- """Not Mac OSX: always return None.
+ """Neither Mac OSX keychain or Gnome keyring available: always return
+ None.
"""
return None
#######################################
def get_password(label, user, server, protocol, logger):
- # try keychain first
+ # try keychain/keyrings first, where available
password = keychain_password(user, server, protocol, logger)
- # if no password found (or not on OSX), prompt in the usual way
- if not password:
+ if password:
+ logger.debug('using password from keychain/keyring')
+ else:
+ # no password found (or not on OSX), prompt in the usual way
password = getpass.getpass('Enter password for %s: ' % label)
return password
|