mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-09 22:38:19 +02:00
Minor cleanup & a Python 3k fix.
This commit is contained in:
parent
e50408e365
commit
05c8d3ece8
2 changed files with 16 additions and 4 deletions
|
|
@ -111,10 +111,14 @@ def fetch_user_info(email):
|
|||
def fetch_google_contacts(email, limit=10000):
|
||||
result = google_api_get(
|
||||
email,
|
||||
"https://www.google.com/m8/feeds/contacts/default/full?v=3.0&alt=json&max-results=%s" % limit
|
||||
"https://www.google.com/m8/feeds/contacts/default/full"
|
||||
"?v=3.0&alt=json&max-results=%s" % limit
|
||||
)
|
||||
entries = result['feed']['entry']
|
||||
valid_entries = [x for x in entries if u'gd$email' in x.keys() and u'gd$name' in x.keys()]
|
||||
valid_entries = [
|
||||
x for x in entries
|
||||
if u'gd$email' in x.keys() and u'gd$name' in x.keys()
|
||||
]
|
||||
contacts = []
|
||||
for each in valid_entries:
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
import logging
|
||||
|
||||
from django_mailbox.transports.imap import ImapTransport
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class GmailImapTransport(ImapTransport):
|
||||
|
||||
def connect(self, username, password):
|
||||
|
|
@ -7,7 +13,7 @@ class GmailImapTransport(ImapTransport):
|
|||
try:
|
||||
self._connect_oauth(username)
|
||||
except (TypeError, ValueError) as e:
|
||||
print " Couldn't do oauth2 because %s" % e
|
||||
logger.warning("Couldn't do oauth2 because %s" % e)
|
||||
self.server = self.transport(self.hostname, self.port)
|
||||
typ, msg = self.server.login(username, password)
|
||||
self.server.select()
|
||||
|
|
@ -37,7 +43,9 @@ class GmailImapTransport(ImapTransport):
|
|||
pass
|
||||
except AccessTokenNotFound:
|
||||
raise ValueError(
|
||||
"No Token available in python-social-auth for %s" % username
|
||||
"No Token available in python-social-auth for %s" % (
|
||||
username
|
||||
)
|
||||
)
|
||||
|
||||
auth_string = 'user=%s\1auth=Bearer %s\1\1' % (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue