summaryrefslogtreecommitdiff
path: root/src/leap/eip/openvpnconnection.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-11-14 00:33:05 +0900
committerkali <kali@leap.se>2012-11-14 00:33:05 +0900
commitd24c7328fa845737dbb83d512e4b3f287634c4cc (patch)
treeae0409bd742ce3a6f994ae9bb31fc5ab7225f1c6 /src/leap/eip/openvpnconnection.py
parentd2dcf5a1060d60c451570349a6a06ad102d6924c (diff)
make tests pass + pep8
They were breaking mainly because I did not bother to have a pass over them to change the PROVIDER settings from the branding case. All good now, although much testing is yet needed and some refactor could be used. long live green tests!
Diffstat (limited to 'src/leap/eip/openvpnconnection.py')
-rw-r--r--src/leap/eip/openvpnconnection.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/leap/eip/openvpnconnection.py b/src/leap/eip/openvpnconnection.py
index 34f1e18b..4104bd0e 100644
--- a/src/leap/eip/openvpnconnection.py
+++ b/src/leap/eip/openvpnconnection.py
@@ -233,8 +233,8 @@ to be triggered for each one of them.
#self.tn.read_until('ENTER PASSWORD:', 2)
#self.tn.write(self.password + '\n')
#self.tn.read_until('SUCCESS:', 2)
-
- self._seek_to_eof()
+ if self.tn:
+ self._seek_to_eof()
return True
def _seek_to_eof(self):
@@ -364,7 +364,8 @@ to be triggered for each one of them.
interface
"""
logger.debug("disconnecting...")
- self._send_command("signal SIGTERM\n")
+ if self.connected():
+ self._send_command("signal SIGTERM\n")
if self.subp:
return True
@@ -373,9 +374,13 @@ to be triggered for each one of them.
#try patching in old openvpn host and trying again
process = self._get_openvpn_process()
if process:
- self.host = \
- process.cmdline[process.cmdline.index("--management") + 1]
- self._send_command("signal SIGTERM\n")
+ logger.debug('process :%s' % process)
+ cmdline = process.cmdline
+
+ if isinstance(cmdline, list):
+ _index = cmdline.index("--management")
+ self.host = cmdline[_index + 1]
+ self._send_command("signal SIGTERM\n")
#make sure the process was terminated
process = self._get_openvpn_process()