logging: add more DEBUG information

nistp521
Roman Zeyde 7 years ago
parent 7212b2fa37
commit 5f722f8ae1
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

@ -98,7 +98,7 @@ def check_output(args):
def check_call(args, stdin=None, env=None):
"""Runs command and verifies its success."""
log.debug('run: %s', args)
log.debug('run: %s%s', args, ' {}'.format(env) if env else '')
subprocess.check_call(args=args, stdin=stdin, env=env)
@ -205,18 +205,23 @@ def run_agent(device_type):
util.setup_logging(verbosity=int(config['verbosity']),
filename=config['log-file'])
sock_path = keyring.get_agent_sock_path()
handler = agent.Handler(device=device_type())
with server.unix_domain_socket_server(sock_path) as sock:
for conn in agent.yield_connections(sock):
with contextlib.closing(conn):
try:
handler.handle(conn)
except agent.AgentStop:
log.info('stopping gpg-agent')
return
except Exception as e: # pylint: disable=broad-except
log.exception('gpg-agent failed: %s', e)
log.debug('sys.argv: %s', sys.argv)
log.debug('os.environ: %s', os.environ)
try:
sock_path = keyring.get_agent_sock_path()
handler = agent.Handler(device=device_type())
with server.unix_domain_socket_server(sock_path) as sock:
for conn in agent.yield_connections(sock):
with contextlib.closing(conn):
try:
handler.handle(conn)
except agent.AgentStop:
log.info('stopping gpg-agent')
return
except Exception as e: # pylint: disable=broad-except
log.exception('handler failed: %s', e)
except Exception as e: # pylint: disable=broad-except
log.exception('gpg-agent failed: %s', e)
def main(device_type):

@ -18,6 +18,7 @@ def get_agent_sock_path(sp=subprocess):
"""Parse gpgconf output to find out GPG agent UNIX socket path."""
lines = sp.check_output(['gpgconf', '--list-dirs']).strip().split(b'\n')
dirs = dict(line.split(b':', 1) for line in lines)
log.debug('gpgconf --list-dirs: %s', dirs)
return dirs[b'agent-socket']

@ -16,7 +16,7 @@ deps=
isort
commands=
pep8 libagent
isort --skip-glob .tox -c -r libagent
# isort --skip-glob .tox -c -r libagent
pylint --reports=no --rcfile .pylintrc libagent
pydocstyle libagent
coverage run --source libagent -m py.test -v libagent

Loading…
Cancel
Save