API: connect to managesieve server
490428
public function connect($username, $password)
    {
        $error = parent::connect($username, $password);

        if ($error) {
            return $error;
        }

        return $this->load_script();
    }
1165631
function serve() {
  util.log(util.colors.green('Serving unminified js'));

  nodemon({
    script: require.resolve('../server/server.js'),
    watch: [
      require.resolve('../server/server.js')
    ],
    env: {
      'NODE_ENV': 'development',
      'SERVE_PORT': port,
      'SERVE_HOST': host,
      'SERVE_USEHTTPS': useHttps,
      'SERVE_PROCESS_ID': process.pid,
      'SERVE_QUIET': quiet
    },
  })
  .once('quit', function () {
    util.log(util.colors.green('Shutting down server'));
  });
  if (!quiet) {
    util.log(util.colors.yellow('Run `gulp build` then go to ' + getHost()));
  }
}
1293980
def add_connectionmanager_api(mock):
    ''''''

    iface = 'org.ofono.ConnectionManager'
    mock.AddProperties(iface, {
        'Attached': _parameters.get('Attached', True),
        'Bearer': _parameters.get('Bearer', 'gprs'),
        'RoamingAllowed': _parameters.get('RoamingAllowed', False),
        'Powered': _parameters.get('ConnectionPowered', True),
    })
    mock.AddMethods(iface, [
        ('GetProperties', '', 'a{sv}', 'ret = self.GetAll("%s")' % iface),
        ('SetProperty', 'sv', '', 'self.Set("%(i)s", args[0], args[1]); '
         'self.EmitSignal("%(i)s", "PropertyChanged", "sv", [args[0], args[1]])' % {'i': iface}),
        ('AddContext', 's', 'o', 'ret = "/"'),
        ('RemoveContext', 'o', '', ''),
        ('DeactivateAll', '', '', ''),
        ('GetContexts', '', 'a(oa{sv})', 'ret = dbus.Array([])'),
    ])
319152
function generateAdminRouter(conf) {
  var awsKey = conf.aws.key;
  var awsSecret = conf.aws.secret;

  var api = apiFactory(log);
  var p = q.defer();

  // Register backup handlers:

  backup.registerHandler('s3', backupHandlers.genS3BackupHandler(
        awsKey,
        awsSecret
  ));

  MongoClient.connect(conf.database.url, function(err, db) {
    if(err) {
      p.reject(err);
      return;
    }

    var backupCollection = db.collection(BACKUP_COLLECTION_NAME);
    var liveBackups = {};

    //Lists all persisted backups
    api.register('backup', 'list', 'GET', function() {
        var results = backupCollection.find({});
        return q.nbind(results.toArray, results)();
    });

    api.register('backup', 'stat', 'GET', [ 'id' ], function(id) {
      if(liveBackups[id]) {
        return q(liveBackups[id]);
      }

      return q.nbind(backupCollection.findOne, backupCollection)({ backupId: id })
        .then(function(r) {
          if(!r) {
            return q({ 'error': true, msg: 'backup with id ' + id + ' not found'});
          }

          return q({ 'status': 'saved' });
        });
    });

    //Request object must be of the form
    //  {
    //    collections: [<String>],
    //    type: <String>,
    //    opts: <Object>
    //  }
    api.register('backup', 'start', 'POST', function(args) {
      var id = uuid.v1();
      // TODO: add a call to mongo's admin.serverStatus function to get the time on server.
      var backupTimestamp = new Date();
      liveBackups[id] = { 'status': 'in-progress' };
      backup.create(conf.backups.target, args.collections, args.type, args.opts)
        .then(function(backupRecord) {
          backupRecord.name = args.name;
          backupRecord.timestamp = backupTimestamp.toISOString();
          backupRecord.backupId = id;
          backupCollection.insert(backupRecord, function(e) {
            if(e) {
              liveBackups[id] = { 'status': 'failed' };
              log.error(e);
            }
            delete liveBackups[id];
          });
        })
        .then(null, log.error.bind(log));
      return q({id: id});
    });


    //FIXME use tickets to manage restore ops (similar to backups)

    api.register('backup', 'restore', 'POST', function(args) {
      var id = args.id;
      return q.nbind(backupCollection.findOne, backupCollection)({ backupId: id })
        .then(function(r) {
          if(!r) {
            return q({ error: true, msg: 'backup with id ' + id + ' not found ' });
          }
          return backup.restore(r, conf.backups.target);
        });
    });

    p.resolve(api.getApp());
  });

  return p.promise;
}
876559
def connect(nickname, server_def, debug=None, timeout=10):
    
    url = server_def.url
    conn = pywbem.WBEMConnection(
        url,
        (server_def.user, server_def.password),
        default_namespace=server_def.implementation_namespace,
        no_verification=server_def.no_verification,
        timeout=timeout)
    if debug:
        conn.debug = True

    ns = server_def.implementation_namespace if \
        server_def.implementation_namespace \
        else 'interop'
    try:
        conn.GetQualifier('Association', namespace=ns)
        return conn
    except pywbem.ConnectionError as exc:
        print("Test server {0} at {1!r} cannot be reached. {2}: {3}".
              format(nickname, url, exc.__class__.__name__, exc))
        return None
    except pywbem.AuthError as exc:
        print("Test server {0} at {1!r} cannot be authenticated with. "
              "{2}: {3}". format(nickname, url,
                                 exc.__class__.__name__, exc))
        return None
    except pywbem.CIMError as ce:
        if ce.status_code == pywbem.CIM_ERR_NAMESPACE_NOT_FOUND or \
                ce.status.code == pywbem.CIM_ERR_NOT_FOUND:
            return conn
        else:
            return None
    except pywbem.Error as exc:
        print("Test server {0} at {1!r} returned exception. {2}: {3}".
              format(nickname, url, exc.__class__.__name__, exc))
    return None
1147932
function executeApiCall(callback, needConnection) {
        needConnection = typeof needConnection !== 'undefined' ? needConnection : true;
        authenticate(function (error, result) {
            if (error || !result) {
                callback(error, result);
                return;
            }
            if (needConnection) {
                isConnected(function (error, result) {
                    if (error || !result) {
                        console.error("[Deluge] WebUI not connected to a daemon");
                        return;
                    }
                    callback(error, result);
                });
            } else {
                callback(error, result);
            }
        });
    }
8948
def _connect(self):
        """"""
        cls = self._get_manager_class(register_callables=False)
        ins = cls(address=self.addr, authkey=self.authkey)
        ins.connect()
        return ins
755421
function(connect, options) {
          return [
            require('connect-livereload')(),
            // Default middlewares
            // Serve static files.
            connect.static(options.base),
            // Make empty directories browsable.
            connect.directory(options.base)
          ];
        }
778233
def update(self, name=None, algorithm=None, protocol=None, halfClosed=None,
            port=None, timeout=None, httpsRedirect=None):
        
        return self.manager.update(self, name=name, algorithm=algorithm,
                protocol=protocol, halfClosed=halfClosed, port=port,
                timeout=timeout, httpsRedirect=httpsRedirect)
924863
def run():
    
    server_address = (args.listen_addr, args.listen_port)
    httpd = YHSM_VALServer(server_address, YHSM_VALRequestHandler)
    my_log_message(args, syslog.LOG_INFO, "Serving requests to 'http://%s:%s%s' (YubiHSM: '%s')" \
                       % (args.listen_addr, args.listen_port, args.serve_url, args.device))
    httpd.serve_forever()
22980
function server() {
  // TODO: Show require express error
  var express = require('express')
    , app = express();

  app.configure(function() {
    app.use(express.static(siteBuilder.outputRoot));
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
  });

  // Map missing trailing slashes for posts
  app.get('*', function(req, res) {
    var postPath = siteBuilder.outputRoot + req.url + '/';
    // TODO: Security
    if (req.url.match(/[^/]$/) && existsSync(postPath)) {
      res.redirect(req.url + '/');
    } else {
      res.send('404');
    }
  });

  app.listen(siteBuilder.config.port);
  log.info('Listening on port', siteBuilder.config.port);
}
674053
def connect(self, username=None, passcode=None, wait=False, headers=None, **keyword_headers):
        
        self.transport.start()
971543
function createDefaultMiddleware(connect, options) {
					var middlewares = [];

					var directory = options.directory || options.base;
					// Serve static files.
					middlewares.push(serveStatic(options.base));
					// Make directory browse-able.
					middlewares.push(serveIndex(directory));
					return middlewares;
				}
24175
function getManagementToken(tenant, config = defaultConfig) {
  const payload = {
    service: tenant,
    username: config.dojot.management.user
  };
  return (
    new Buffer("jwt schema").toString("base64") +
    "." +
    new Buffer(JSON.stringify(payload)).toString("base64") +
    "." +
    new Buffer("dummy signature").toString("base64")
  );
}
1087698
def ucs_manager_connect(self, ucsm_ip):
        """"""
        if not self.ucsmsdk:
            self.ucsmsdk = self._import_ucsmsdk()

        ucsm = CONF.ml2_cisco_ucsm.ucsms.get(ucsm_ip)

        if not ucsm or not ucsm.ucsm_username or not ucsm.ucsm_password:
            LOG.error('UCS Manager network driver failed to get login '
                      'credentials for UCSM %s', ucsm_ip)
            return None

        handle = self.ucsmsdk.handle(ucsm_ip, ucsm.ucsm_username,
                                     ucsm.ucsm_password)
        try:
            handle.login()
        except Exception as e:
            # Raise a Neutron exception. Include a description of
            # the original  exception.
            raise cexc.UcsmConnectFailed(ucsm_ip=ucsm_ip, exc=e)

        return handle
956966
function connect () {
  // connection
  if (!alreadyConnectedOnce) {
    if (connectedPromise === null) connection = createConnection()
    var url = AppConfig.apiUrl + 'websocket/chat'
    if (accessToken) {
      token = accessToken
      url += '?access_token=' + accessToken
    }
    socket = new SockJS(url)
    stompClient = webstomp.over(socket)
    // stompClient.debug = null
    console.tron.log(`Connecting to ${url}`)
    var headers = {}
    stompClient.connect(headers, onConnect, onError)
    alreadyConnectedOnce = true
  }
}
365550
def connect(self, clientId=0, host="localhost", port=4001):
        
        self.clientId = clientId
        self.host = host
        self.port = port
        self.ibConn = Connection.create(
            host=self.host,
            port=int(self.port),
            clientId=self.clientId
        )

        # Assign server messages handling function.
        self.ibConn.registerAll(self.handleServerEvents)

        # connect
        self.log.info("[CONNECTING TO IB]")
        self.ibConn.connect()

        # get server time
        self.getServerTime()

        # subscribe to position and account changes
        self.subscribeAccount = False
        self.requestAccountUpdates(subscribe=True)

        self.subscribePositions = False
        self.requestPositionUpdates(subscribe=True)

        # load working orders
        self.requestOpenOrders()

        # force refresh of orderId upon connect
        self.handleNextValidId(self.orderId)

        self._disconnected_by_user = False
        time.sleep(1)