From 5d2a72486a8ef72659df813e1c0feed41da3a667 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Mon, 12 May 2008 12:32:24 -0300 Subject: [PATCH] Give a nice error if a VPN key can't be readed (refs #22). --- pymin/services/vpn/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pymin/services/vpn/__init__.py b/pymin/services/vpn/__init__.py index dead949..ec6fd50 100644 --- a/pymin/services/vpn/__init__.py +++ b/pymin/services/vpn/__init__.py @@ -160,10 +160,16 @@ class VpnHandler(Restorable, ConfigWriter, log.debug(u'VpnHandler._write_config: creating key...') call(('tincd', '-n', v.vpn_src, '-K', '<', '/dev/null')) #open the created files and load the keys - f = file(path.join(self._config_writer_cfg_dir, - v.vpn_src, 'rsa_key.pub'), 'r') - pub = f.read() - f.close() + try: + f = file(path.join(self._config_writer_cfg_dir, + v.vpn_src, 'rsa_key.pub'), + 'r') + pub = f.read() + f.close() + except (IOError, OSError), e: + raise HandlerError(u"Can't read VPN key '%s' (%s)'" + % (e.filename, e.strerror)) + v.pub_key = pub v.priv_key = priv except ExecutionError, e: -- 2.43.0