How to use the ptyprocess.ptyprocess.PtyProcessError function in ptyprocess

To help you get started, we’ve selected a few ptyprocess examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github barjomet / vpnocchio / vpnocchio.py View on Github external
def disconnect(self):
        if self.vpn_process is not None:
            try:
                self._terminate()
            except ValueError:
                self._kill()
            time.sleep(0.5)
            while self._is_running:
                if self.use_pexpect:
                    try:
                        self.vpn_process.close(True)
                    except ptyprocess.ptyprocess.PtyProcessError:
                        pass
                else:
                    self.vpn_process.wait()
                time.sleep(0.1)
            self.connected = False
            try:
                self.instances.remove(self)
            except ValueError:
                pass
            self.vpn_process = self.ip = self.conf_file = None
            self.log.info('Disconnected')
        else:
            self.log.warning('Not connected')