Skip to content

Commit

Permalink
addressbook: add logging statements
Browse files Browse the repository at this point in the history
to help troubleshoot problems
  • Loading branch information
teto authored and pazz committed Feb 6, 2019
1 parent fff58de commit 0a55181
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions alot/addressbook/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from ..helper import call_cmd
from ..helper import split_commandstring
from . import AddressBook, AddressbookError
import logging


class ExternalAddressbook(AddressBook):
Expand Down Expand Up @@ -59,9 +60,11 @@ def _call_and_parse(self, commandline):
raise AddressbookError(msg)

if not resultstring:
logging.debug("No contacts in address book (empty string)")
return []
lines = resultstring.splitlines()
res = []
logging.debug("Apply %s on %d results" % (self.regex, len(lines)))
for l in lines:
m = re.match(self.regex, l, self.reflags)
if m:
Expand All @@ -70,4 +73,5 @@ def _call_and_parse(self, commandline):
email = info['email'].strip()
name = info['name']
res.append((name, email))
logging.debug("New match name=%s mail=%s" % (name, email))
return res
2 changes: 2 additions & 0 deletions alot/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ def call_cmd(cmdlist, stdin=None):
if isinstance(stdin, str):
stdin = stdin.encode(termenc)
try:

logging.debug("Calling %s" % cmdlist)
proc = subprocess.Popen(
cmdlist,
stdout=subprocess.PIPE,
Expand Down

0 comments on commit 0a55181

Please sign in to comment.