Open the connection if not already open.

        :return: True
351727
def open(self):
        
        try:
            if self.conn.get_backend_pid():
                return True
        except psycopg2.InterfaceError as e:
            if str(e) == "connection already closed":
                # We already lost our connection. Attempt to reforge it.
                self.__reconnect__()
                if self.conn.get_backend_pid() >= 0:
                    return True # Resets it.
            else:
                raise e
342277
def on_connection_open(self, unused_connection):
        
        self._logger.info('Connection opened')
        self.add_on_connection_close_callback()
        self.open_channel()
305693
def wait_for_connection(self, timeout=10):
        
        start_time = datetime.datetime.now()
        while True:
            if self.connected:
                return True
            now = datetime.datetime.now()
            if (now - start_time).total_seconds() > timeout:
                return False
            time.sleep(0.5)
531122
def _open_connection(self):
        
        if self._scheme == 'unix':
            self._connection = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0)
            self._connection.connect(self._path)
        elif self._scheme == 'tcp':
            self._connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.SOL_TCP)
            self._connection.connect((self._host, self._port))
        elif self._scheme == 'http':
            self._connection =  httplib.HTTPConnection(self._host, self._port, strict=False)
        else:
            raise ConnectionError("Connection scheme not recognized!")
956552
def open(self) -> bool:
        
        if self.connection:
            # Nothing to do if the connection is already open.
            return False

        connection_params = {'local_hostname': DNS_NAME.get_fqdn()}
        if self.timeout is not None:
            connection_params['timeout'] = self.timeout
        try:
            self.connection = smtplib.SMTP(self.host, self.port,
                                           **connection_params)

            # TLS
            context = ssl.SSLContext(self._protocol())
            if self.ssl_certfile:
                context.load_cert_chain(certfile=self.ssl_certfile,
                                        keyfile=self.ssl_keyfile)
            self.connection.ehlo()
            self.connection.starttls(context=context)
            self.connection.ehlo()
            if self.username and self.password:
                self.connection.login(self.username, self.password)
                log.debug("Successful SMTP connection/login")
            else:
                log.debug("Successful SMTP connection (without login)")
            return True
        except smtplib.SMTPException:
            log.debug("SMTP connection and/or login failed")
            if not self.fail_silently:
                raise
1213677
def open_connection(self):
        
        self.logger.debug("Open CLI Process '%s'",
                          (self.comport), extra={'type': '<->'})
        self.cmd = self.comport if isinstance(self.comport, list) else [self.comport]
        if not self.comport:
            raise DutConnectionError("Process not defined!")
        try:
            self.build = Build.init(self.cmd[0])
        except NotImplementedError as error:
            self.logger.error("Build initialization failed. Check your build location.")
            self.logger.debug(error)
            raise DutConnectionError(error)
        # Start process&reader thread. Call Dut.process_dut() when new data is coming
        app = self.config.get("application")
        if app and app.get("bin_args"):
            self.cmd = self.cmd + app.get("bin_args")
        try:
            self.start_process(self.cmd, processing_callback=lambda: Dut.process_dut(self))
        except KeyboardInterrupt:
            raise
        except Exception as error:
            raise DutConnectionError("Couldn't start DUT target process {}".format(error))
991593
def _open(self):
        
        if self._process is not None:
            return

        cmd = [
            'ssh',
            self._host,
            'sudo',
            'buttersink',
            '--server',
            '--mode',
            self._mode,
            self._directory
        ]
        logger.debug("Connecting with: %s", cmd)
        self._process = subprocess.Popen(
            cmd,
            stdin=subprocess.PIPE,
            stderr=sys.stderr,
            # stdout=sys.stdout,
            stdout=subprocess.PIPE,
        )

        version = self.version()
        logger.info("Remote version: %s", version)
210890
def _on_connection_open(self, connection):
        
        _log.info("Successfully opened connection to %s", connection.params.host)
        self._channel = connection.channel(on_open_callback=self._on_channel_open)
224143
async def _connect(self) -> "Connection":
        """"""
        if self._connection is None:
            self._connection = await self._execute(self._connector)
        return self
437306
def _send_open_connection(self):
        
        open_frame = specification.Connection.Open(
            virtual_host=self._parameters['virtual_host']
        )
        self._write_frame(open_frame)
788327
def connectRelay(self):
        
        self.protocol = self.connector.buildProtocol(None)
        self.connected = True
        self.protocol.makeConnection(self)
728312
def open(self):
        
        if self.connection:
            # Nothing to do if the connection is already open.
            return False
        try:
            # If local_hostname is not specified, socket.getfqdn() gets used.
            # For performance, we use the cached FQDN for local_hostname.
            self.connection = smtplib.SMTP(
                self.host, self.port, local_hostname=DNS_NAME.get_fqdn()
            )
            if self.use_tls:
                self.connection.ehlo()
                self.connection.starttls()
                self.connection.ehlo()
            if self.username and self.password:
                self.connection.login(self.username, self.password)
            return True
        except Exception as e:
            logger.error(
                "Error trying to connect to server %s:%s: %s",
                self.host,
                self.port,
                e,
            )
            if not self.fail_silently:
                raise
1291487
def try_open(server)
      options = @options.merge(server.options) # merge connection and server options
      options[:tunnel] ? try_open_tunnel(server, options) : try_open_direct(server, options)
    end
1094483
def reconnect(self):
        """"""
        try:
            self.conn.close()
        except Exception,e:
            self.logger.warn(e)

        self.createConnection()

        return True
544163
def open(self):
        """"""
        url = self.url
        try:
            request = urllib.request.Request(url)
            handle = urllib.request.build_opener()
        except IOError:
            return None
        return (request, handle)
5226
def get_connection_state(self, connection: str) -> Dict[str, Any]:
        
        if connection not in self.connections:
            raise ConnectionNotOpen(connection)

        return self.connections[connection].state
915942
def open_links(self):
        
        if self._is_open:
            raise Exception('Already opened')

        try:
            self.parallel_safe(lambda scf: scf.open_link())
            self._is_open = True
        except Exception as e:
            self.close_links()
            raise e