X-Git-Url: http://git.tremily.us/?a=blobdiff_plain;f=bin%2Fget-info.py;h=bba87c35cc2d27193f8b7e1d208f9cb285620ff1;hb=89a9ab22b2dbb22cf9a22a3d8b9da9e4168b4f25;hp=95c3209c186bdcd297f454b85cf412f73fcc3820;hpb=afdaedac866dd2dfcf242c4742e3d0b619f3aeae;p=pyassuan.git diff --git a/bin/get-info.py b/bin/get-info.py index 95c3209..bba87c3 100755 --- a/bin/get-info.py +++ b/bin/get-info.py @@ -1,6 +1,20 @@ #!/usr/bin/env python3 # -# Copyright +# Copyright (C) 2012 W. Trevor King +# +# This file is part of pyassuan. +# +# pyassuan is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. +# +# pyassuan is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# pyassuan. If not, see . """Simple pinentry program for getting server info. """ @@ -10,6 +24,7 @@ import socket as _socket from pyassuan import __version__ from pyassuan import client as _client from pyassuan import common as _common +from pyassuan import error as _error if __name__ == '__main__': @@ -34,8 +49,8 @@ if __name__ == '__main__': socket = _socket.socket(_socket.AF_UNIX, _socket.SOCK_STREAM) socket.connect(args.filename) - client.input = socket.makefile('r') - client.output = socket.makefile('w') + client.input = socket.makefile('rb') + client.output = socket.makefile('wb') client.connect() try: response = client.read_response() @@ -43,7 +58,13 @@ if __name__ == '__main__': client.make_request(_common.Request('HELP')) client.make_request(_common.Request('HELP GETINFO')) for attribute in ['version', 'pid', 'socket_name', 'ssh_socket_name']: - client.make_request(_common.Request('GETINFO', attribute)) + try: + client.make_request(_common.Request('GETINFO', attribute)) + except _error.AssuanError as e: + if e.message.startswith('No data'): + pass + else: + raise finally: client.make_request(_common.Request('BYE')) client.disconnect()