From 78db9729c2f6714df4739b28d66be845019a1bf6 Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 19 Nov 2012 14:09:24 +0900 Subject: fix delete temporal files --- src/leap/eip/openvpnconnection.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/leap/eip') diff --git a/src/leap/eip/openvpnconnection.py b/src/leap/eip/openvpnconnection.py index 45a1847c..85874cfd 100644 --- a/src/leap/eip/openvpnconnection.py +++ b/src/leap/eip/openvpnconnection.py @@ -214,12 +214,14 @@ to be triggered for each one of them. # delete if self.port == "unix": - # I'm tempted to catch a generic exception here, - # but I prefer to let it crash so we can catch - # specific errors that right now I'm not able - # to think of. logger.debug('cleaning socket file temp folder') - shutil.rmtree(os.path.split(self.host)[0]) + + tempfolder = os.path.split(self.host)[0] + if os.path.isdir(tempfolder): + try: + shutil.rmtree(tempfolder) + except OSError: + logger.error('could not delete tmpfolder %s' % tempfolder) def _get_openvpn_process(self): # plist = [p for p in psutil.get_process_list() if p.name == "openvpn"] -- cgit v1.2.3