From: Leandro Lucarella Date: Mon, 12 May 2008 15:32:24 +0000 (-0300) Subject: Give a nice error if a VPN key can't be readed (refs #22). X-Git-Url: https://git.llucax.com/software/pymin.git/commitdiff_plain/5d2a72486a8ef72659df813e1c0feed41da3a667?ds=sidebyside Give a nice error if a VPN key can't be readed (refs #22). --- 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: