Verify if a connman service is connected
162564
def _connected(service):
    '''
    
    '''
    state = pyconnman.ConnService(os.path.join(SERVICE_PATH, service)).get_property('State')
    return state == 'online' or state == 'ready'
1090222
def get_connected(self):
        
        connected = c_int32()
        result = self.library.Cli_GetConnected(self.pointer, byref(connected))
        check_error(result, context="client")
        return bool(connected)
1336185
def _verify_connection(self):
        
        try:
            res = self._session.get(self._connection_validation_url, json={})
            logger.debug(consts.LOG_MSG_VERIFYING_CONNECTION,
                         self._connection_validation_url,
                         res if res else 'No result from backend')
            if not res.ok:
                raise requests.exceptions.RequestException(res.content)
            remote_batch_size = res.json().get(consts.MAX_REQUEST_SIZE_FIELD,
                                               consts.DEFAULT_BATCH_SIZE)
            if remote_batch_size < self._batch_max_size:
                self._batch_max_size = remote_batch_size
                self._notify(logging.INFO,
                             consts.LOG_MSG_NEW_BATCH_SIZE % remote_batch_size)
            self._is_connected.set()
            return True

        except requests.exceptions.RequestException as ex:
            msg = consts.LOG_MSG_CONNECTION_FAILED % str(ex)
            self._notify(logging.ERROR, msg)
            raise exceptions.ConnectionFailed(msg)
545491
def _check_connection(self):
        """"""
        if ((self.tcp_disconnect_timer + 2 * self.reconnect_timeout) <
                time.time()):
            self.tcp_disconnect_timer = time.time()
            raise OSError('No response from {}. Disconnecting'.format(
                self.server_address))
        if (self.tcp_check_timer + self.reconnect_timeout) >= time.time():
            return
        msg = Message().modify(
            child_id=255, type=self.const.MessageType.internal,
            sub_type=self.const.Internal.I_VERSION)
        self.add_job(msg.encode)
        self.tcp_check_timer = time.time()
391669
def check(self):
        
        try:
            self.get_snmp_from_host1()
            self.get_snmp_from_host2()
        except (health_monitoring_plugins.SnmpException, TypeError, KeyError):
            self.helper.status(unknown)
            self.helper.add_summary("SNMP response incomplete or invalid")
            return

        self.helper.add_summary("Filter Status")
        self.helper.add_long_output("Power Supply 1: %s" % self.ps1_value)
        if self.ps1_value != "ok":
            self.helper.status(critical)
            self.helper.add_summary("Power Supply 1: %s" % self.ps1_value)

        self.helper.add_long_output("Power Supply 2: %s" % self.ps2_value)
        if self.ps2_value != "ok":
            self.helper.status(critical)
            self.helper.add_summary("Power Supply 2: %s" % self.ps2_value)

        self.helper.add_long_output("Fan 1: %s" % self.fan1_value)
        if self.fan1_value != "ok":
            self.helper.status(critical)
            self.helper.add_summary("Fan 1: %s" % self.fan1_value)

        self.helper.add_long_output("Fan 2: %s" % self.fan2_value)
        if self.fan2_value != "ok":
            self.helper.status(critical)
            self.helper.add_summary("Fan 2: %s" % self.fan2_value)

        self.helper.add_long_output("Battery: %s" % self.bat_value)
        if self.bat_value != "ok":
            self.helper.status(critical)
            self.helper.add_summary("Battery: %s" % self.bat_value)

        self.helper.add_long_output("Temperature: %s" % self.temp_value)
        if self.temp_value != "ok":
            self.helper.status(critical)
            self.helper.add_summary("Temperature: %s" % self.temp_value)

        self.helper.add_metric(label='logfill',value=self.logfill_value, uom="%%")
        self.helper.add_long_output("Fill Level internal log: %s%%" % self.logfill_value)

        self.helper.add_long_output("Activity State: %s" % self.activity_value1)
        if self.activity_value1 == "error":
            self.helper.status(critical)
            self.helper.add_summary("Activity State: %s" % self.activity_value1)

        if self.activity_value2:
            self.helper.add_long_output("Activity State 2: %s" % self.activity_value2)
            if self.activity_value1 == "active" and self.activity_value2 == "active":
                self.helper.status(critical)
                self.helper.add_summary("Filter 1 and Filter 2 active!")
                    
            if self.activity_value1 == "standby" and self.activity_value2 == "standby":
                self.helper.status(critical)
                self.helper.add_summary("Filter 1 and Filter 2 standby!")

        self.helper.check_all_metrics()
807298
def service_confirmation(self, conn, bslpdu):
        """"""
        if _debug: ProxyServerService._debug("service_confirmation %r %r", conn, bslpdu)

        # make sure there is an adapter for it - or something went wrong
        if not getattr(conn, 'proxyAdapter', None):
            raise RuntimeError("service confirmation received but no adapter for it")

        # forward along
        conn.proxyAdapter.service_confirmation(bslpdu)
1034401
function ensureConnected(remote, callback) {
  if (remote.getServer()) {
    callback(null, isConnected(remote));
  } else {
    callback(null, false);
  }
}
747178
def after_connect(self):
        """"""
        # TODO: check if this works.
        show_users = self.device.send("show users", timeout=120)
        result = re.search(pattern_manager.pattern(self.platform, 'connected_locally'), show_users)
        if result:
            self.log('Locally connected to Calvados. Exiting.')
            self.device.send('exit')
            return True
        return False
1130221
def get_connection_by_dest(self, dest):
        ''''''
        with self._mutex:
            for conn in self.connections:
                if conn.has_port(self) and conn.has_port(dest):
                    return conn
            return None
955608
function scheduleServerConnectivityChecks() {
        if (connectivityIntervalId === null) {
            connectivityIntervalId = asyncExecService.setInterval(function () {
                updateRegistrations();
                connectToServers();
            }, INTERVAL_BETWEEN_SERVER_CONNECTIVITY_CHECKS);
        }
        else {
            throw new Error("BUG ::: Attempt was made to start connectivity checks twice");
        }
    }
1065050
public function isConnected($which_connection='')
    {
        if ($which_connection == '') {
            $which_connection=$this->default_db;
        }
        if (isset($this->connections[$which_connection]) && 
            is_object($this->connections[$which_connection])) {
            return true;
        } else {
            return false;
        }
    }
60707
async def prepare_conn(self, conn):
        """"""

        client_id = str(uuid.uuid4())
        monitor = functools.partial(self.send_event, client_id)

        self._logger.info("New client connection: %s", client_id)

        self.service_manager.add_monitor(monitor)

        self.clients[client_id] = dict(connection=conn, monitor=monitor)
        return client_id
132768
def _check_connections(self):
        """"""

        for server in self._servers:
            if self._is_reachable(server):
                server['down_until'] = 0
            else:
                server['down_until'] = time.time() + 5
892725
def isConnected(self, fromName, toName):
        
        for c in self.connections:
            if (c.fromLayer.name == fromName and
                c.toLayer.name == toName):
                return 1
        return 0
964872
function (conn) {
            if (!this.__validateConnectionCB) {
                var ret = new Promise();
                ret.callback(true);
                return ret;
            } else {
                return this.__validateConnectionCB(conn);
            }
        }
1164247
def is_connected(self):
        
        try:
            return self.socket is not None and self.socket.getsockname()[1] != 0 and BaseTransport.is_connected(self)
        except socket.error:
            return False
857809
private boolean checkVmIsOnline() {

		String zoneName = OpenstackIaasHandler.findZoneName( this.novaApi, this.targetProperties );
		Server server = this.novaApi.getServerApiForZone( zoneName ).get(this.machineId);
		return Status.ACTIVE.equals(server.getStatus());
	}