Given a ServerConnection and a MOR return the ME

@param sc
@param mor
@return
195722
public static ManagedEntity createExactManagedEntity(ServerConnection sc, ManagedObjectReference mor) {
        return (ManagedEntity) createExactManagedObject(sc, mor);
    }
1266630
public static ScmConnector create(String scmType, String url, String privateKey, String username, String password, String branch, String tag) {
        ScmConnector scmConnector = null;
        if (StringUtils.isNotBlank(scmType)) {
            ScmType type = ScmType.getValue(scmType);
            if (type == null) {
                throw new IllegalArgumentException("Invalid scm type, please select git / svn / mercurial");
            }

            if (StringUtils.isBlank(url)) {
                throw new IllegalArgumentException("No scm link provided");
            }

            switch (type) {
                case GIT:
                    scmConnector = new GitConnector(privateKey, username, password, url, branch, tag);
                    break;
                case SVN:
                    scmConnector = new SvnConnector(username, password, url, branch, tag);
                    break;
                case MERCURIAL:
                    scmConnector = new MercurialConnector(username, password, url, branch, tag);
                    break;
                default: throw new IllegalArgumentException("Unsupported scm type");
            }
        }
        return scmConnector;
    }
575065
public ConnectionRepository readConnectionRepository(InputStream inst)
            throws MalformedURLException, ParserConfigurationException, SAXException, IOException
    {
        long duration = System.currentTimeMillis();
        InputSource inSource = new InputSource(inst);
        ConnectionRepository result = (ConnectionRepository) readMetadataFromXML(inSource, ConnectionRepository.class);
        log.info("Read connection repository took " + (System.currentTimeMillis() - duration) + " ms");
        return result;
    }
67461
def Convert(self, metadata, conn, token=None):
    """"""

    result = ExportedNetworkConnection(
        metadata=metadata,
        family=conn.family,
        type=conn.type,
        local_address=conn.local_address,
        remote_address=conn.remote_address,
        state=conn.state,
        pid=conn.pid,
        ctime=conn.ctime)
    return [result]
1144527
async function request(cb) {
  // get name of current service, stop if it's `config-srv` itself
  const name = nconf.get('server:name') || 'test-srv';
  let data = {};
  if (name === 'config-srv') return cb(null, data);

  // setup & connect with config-srv on first run
  // if (!client && fs.existsSync(fullProtoPath))
  const config = _.clone(nconf.get('config-srv'));
  let service;

  if (config.transports
    && config.transports.grpc
    && config.transports.service) {
    client = new grpcClient.Client(config);
    service = await co(client.connect());
  } else {
    throw new Error('Missing configuration details');
  }

  await co(service.get({
    filter: client.toStruct({ name: name })
  }));

  // TODO: continue
  // fetch the latest configuration data if possible
  client.get({ field: [{ name }] }, (err, res) => {
    if (err) return cb(err, null);
    if (res.data) data = res.data;

    // update/mutate the nconf store and return
    nconf.use('default', data);
    return cb(null, nconf);
  });
  return true;
}
684536
def Morlet (sampr, freq, width=7.0):
  
  dt = 1. / sampr
  sf = freq / width # sf in Hz
  st = 1. / (2. * np.pi * sf) # st in s
  t = np.arange(-3.5*st, 3.5*st, dt)
  A = 1. / (st * np.sqrt(2.*np.pi)) # A in 1 / s
  # units: 1/s * (exp (s**2 / s**2)) * exp( 1/ s * s)
  return A * np.exp(-t**2. / (2. * st**2.)) * np.exp(1.j * 2. * np.pi * freq * t)
1348465
function laRoute(client, serverType, msg, cb) {
    const servers = client._station.serversMap[serverType];
    if (!servers || !servers.length) {
        utils.invokeCallback(cb, new Error(`rpc servers not exist with serverType: ${serverType}`));
        return;
    }
    const actives = [];
    if (!client.laParam) {
        client.laParam = {};
    }
    if (client.laParam[serverType]) {
        for (let j = 0; j < servers.length; j++) {
            let count = client.laParam[serverType][servers[j]];
            if (!count) {
                count = 0;
                client.laParam[servers[j]] = 0;
            }
            actives.push(count);
        }
    } else {
        client.laParam[serverType] = {};
        for (let i = 0; i < servers.length; i++) {
            client.laParam[serverType][servers[i]] = 0;
            actives.push(0);
        }
    }
    let rs = [];
    let minInvoke = Number.MAX_VALUE;
    for (let k = 0; k < actives.length; k++) {
        if (actives[k] < minInvoke) {
            minInvoke = actives[k];
            rs = [];
            rs.push(servers[k]);
        } else if (actives[k] === minInvoke) {
            rs.push(servers[k]);
        }
    }
    const index = Math.floor(Math.random() * rs.length);
    const serverId = rs[index];
    client.laParam[serverType][serverId] += 1;
    utils.invokeCallback(cb, null, serverId);
}
1204729
@Nonnull
  public EChange setConnectionTimeoutMilliSecs (final long nMilliSecs)
  {
    if (m_nConnectionTimeoutMilliSecs == nMilliSecs)
      return EChange.UNCHANGED;
    m_nConnectionTimeoutMilliSecs = nMilliSecs;
    return EChange.CHANGED;
  }
1264838
def get_connection(service, module=None, region=None, key=None, keyid=None,
                   profile=None):
    '''
    
    '''

    # future lint: disable=blacklisted-function
    module = str(module or service)
    module, submodule = (str('boto.') + module).rsplit(str('.'), 1)
    # future lint: enable=blacklisted-function

    svc_mod = getattr(__import__(module, fromlist=[submodule]), submodule)

    cxkey, region, key, keyid = _get_profile(service, region, key,
                                             keyid, profile)
    cxkey = cxkey + ':conn'

    if cxkey in __context__:
        return __context__[cxkey]

    try:
        conn = svc_mod.connect_to_region(region, aws_access_key_id=keyid,
                                         aws_secret_access_key=key)
        if conn is None:
            raise SaltInvocationError('Region "{0}" is not '
                                      'valid.'.format(region))
    except boto.exception.NoAuthHandlerFound:
        raise SaltInvocationError('No authentication credentials found when '
                                  'attempting to make boto {0} connection to '
                                  'region "{1}".'.format(service, region))
    __context__[cxkey] = conn
    return conn
793323
@SuppressWarnings("unchecked")
  public final <T> boolean cas(final String key, final int exp, GetsResponse<T> getsReponse,
      final CASOperation<T> operation)
      throws TimeoutException, InterruptedException, MemcachedException {

    return this.cas(key, exp, getsReponse, operation, this.transcoder);
  }
949677
private static GatekeeperReply jmConnect(GSSCredential cred,
					     GlobusURL jobURL,
					     String msg)
	throws GramException, GSSException {

	GSSManager manager = ExtendedGSSManager.getInstance();

	GatekeeperReply reply = null;
	GssSocket socket = null;

	try {

	    ExtendedGSSContext context =
		(ExtendedGSSContext)manager.createContext(null,
							  GSSConstants.MECH_OID,
							  cred,
							  GSSContext.DEFAULT_LIFETIME);

	    context.setOption(GSSConstants.GSS_MODE,
			      GSIConstants.MODE_SSL);

	    GssSocketFactory factory = GssSocketFactory.getDefault();

	    socket = (GssSocket)factory.createSocket(jobURL.getHost(),
						     jobURL.getPort(),
						     context);

	    socket.setAuthorization(SelfAuthorization.getInstance());

	    OutputStream out = socket.getOutputStream();
	    InputStream in   = socket.getInputStream();

	    out.write(msg.getBytes());
	    out.flush();

	    debug("JM SENT:", msg);

	    reply = new GatekeeperReply(in);

	} catch(IOException e) {
	    throw new GramException(GramException.ERROR_CONNECTION_FAILED, e);
	} finally {
	    if (socket != null) {
		try { socket.close(); } catch (Exception e) {}
	    }
	}

	debug("JM RECEIVED:", reply);

	// must be 200 otherwise throw exception
	checkHttpReply(reply.httpCode);

	// protocol version must match
	checkProtocolVersion(reply.protocolVersion);

	return reply;
    }
974429
public static Element getEnvelope(SOAPMessage m){
        try{
            return m.getSOAPPart().getEnvelope();
        }catch (Exception e){
            throw S1SystemError.wrap(e);
        }
    }
547130
JmsConnectionImpl instantiateConnection(JmsJcaConnection jcaConnection, Map<String, String> _passThruProps) throws JMSException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "instantiateConnection", jcaConnection);
        JmsConnectionImpl jmsConnection = new JmsConnectionImpl(jcaConnection, isManaged(), _passThruProps);
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "instantiateConnection", jmsConnection);
        return jmsConnection;
    }
496631
@Override
  public Realm matchRealm(IRequest request) {
    try {
      // once again casting...
      IMessage req = (IMessage) request;
      String destinationRealm = req.getAvps().getAvp(Avp.DESTINATION_REALM).getDiameterIdentity();
      // we have req, we need match, not dummy longest from right BS match.
      return this.matchRealm(req, destinationRealm);
    }
    catch (Exception e) {
      logger.error("Unable to read Destination-Realm AVP to match realm to request", e);
    }

    return null;
  }
383475
function getSC() {
  const sc = [];

  if (pos >= tokensLength) return sc;

  while (pos < tokensLength) {
    const childType = tokens[pos].sc_child;

    if (childType === 1) sc.push(getS());
    else if (childType === 2) sc.push(getCommentML());
    else break;
  }

  return sc;
}
39674
public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo info)
	{
		Util.log("In OTMJCAManagedConnectionFactory.createManagedConnection");
		try
		{
			Kit kit = getKit();
			PBKey key = ((OTMConnectionRequestInfo) info).getPbKey();
			OTMConnection connection = kit.acquireConnection(key);
			return new OTMJCAManagedConnection(this, connection, key);
		}
		catch (ResourceException e)
		{
			throw new OTMConnectionRuntimeException(e.getMessage());
		}
	}
146394
def asa_scp_handler(ssh_conn, cmd="ssh scopy enable", mode="enable"):
    """"""
    if mode == "disable":
        cmd = "no " + cmd
    return ssh_conn.send_config_set([cmd])