NB: Expose the tor process to userland
355725
function connect() {
    let port = null;

    try {
      port = parseInt(readFileSync(path.join(
        datadir,
        'control-port'
      )).toString().split(':')[1]);
    } catch (err) {
      /* istanbul ignore next */
      portFileReads++;

      /* istanbul ignore next */
      if (portFileReads <= 20) {
        return setTimeout(() => connect(), 1000);
      } else {
        return controller.emit('error',
                               new Error('Failed to read control port'));
      }
    }

    socket.connect(port, '127.0.0.1');
  }
1061624
def process_raw_data(cls, raw_data):
        """"""
        properties = raw_data["properties"]

        address_pools = []
        for content in properties.get("loadBalancerBackendAddressPools", []):
            resource = Resource.from_raw_data(content)
            address_pools.append(resource)
        properties["loadBalancerBackendAddressPools"] = address_pools

        nat_rules = []
        for content in properties.get("loadBalancerInboundNatRules", None):
            resource = Resource.from_raw_data(content)
            nat_rules.append(resource)
        properties["loadBalancerInboundNatRules"] = nat_rules

        raw_content = properties.get("publicIPAddress", None)
        if raw_content is not None:
            resource = Resource.from_raw_data(raw_content)
            properties["publicIPAddress"] = resource

        raw_content = properties.get("serviceInsertion", None)
        if raw_content is not None:
            resource = Resource.from_raw_data(raw_content)
            properties["serviceInsertion"] = resource

        raw_content = properties.get("subnet", None)
        if raw_content is not None:
            resource = Resource.from_raw_data(raw_content)
            properties["subnet"] = resource

        return super(IPConfiguration, cls).process_raw_data(raw_data)
446084
def process_raw_data(cls, raw_data):
        """"""
        properties = raw_data.get("properties", {})

        frontend_ip_configurations = []
        for raw_content in properties.get("frontendIPConfigurations", []):
            resource = Resource.from_raw_data(raw_content)
            frontend_ip_configurations.append(resource)
        properties["frontendIPConfigurations"] = frontend_ip_configurations

        raw_content = properties.get("backendAddressPool", None)
        if raw_content is not None:
            resource = Resource.from_raw_data(raw_content)
            properties["backendAddressPool"] = resource

        raw_content = properties.get("probe", None)
        if raw_content is not None:
            resource = Resource.from_raw_data(raw_content)
            properties["probe"] = resource

        return super(LoadBalancingRules, cls).process_raw_data(raw_data)
913338
public void onUnknownHost(String host, SshPublicKey pk) {
		try {
			System.out.println("The host " + host
					+ " is currently unknown to the system");
			System.out.println("The MD5 host key " + "(" + pk.getAlgorithm()
					+ ") fingerprint is: " + pk.getFingerprint());
			System.out.println("The SHA1 host key "
					+ "("
					+ pk.getAlgorithm()
					+ ") fingerprint is: "
					+ SshKeyFingerprint.getFingerprint(pk.getEncoded(),
							SshKeyFingerprint.SHA1_FINGERPRINT));
			try {
				System.out.println("The SHA256 host key "
						+ "("
						+ pk.getAlgorithm()
						+ ") fingerprint is: "
						+ SshKeyFingerprint.getFingerprint(pk.getEncoded(),
								SshKeyFingerprint.SHA256_FINGERPRINT));
			} catch (Exception ex) {
			}

			getResponse(host, pk);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
87075
def start_accepting_passive_host_checks(self):
        
        # todo: #783 create a dedicated brok for global parameters
        if not self.my_conf.accept_passive_host_checks:
            self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_PASSIVE_CHECKS_ENABLED"].value
            self.my_conf.accept_passive_host_checks = True
            self.my_conf.explode_global_conf()
            self.daemon.update_program_status()
256391
def resolve(tor_endpoint, hostname):
    
    if six.PY2 and isinstance(hostname, str):
        hostname = unicode(hostname)  # noqa
    elif six.PY3 and isinstance(hostname, bytes):
        hostname = hostname.decode('ascii')
    factory = _TorSocksFactory(
        hostname, 0, 'RESOLVE', None,
    )
    proto = yield tor_endpoint.connect(factory)
    result = yield proto.when_done()
    returnValue(result)
515838
def cli(env, identifier):
    """"""

    mgr = SoftLayer.NetworkManager(env.client)
    global_ip_id = helpers.resolve_id(mgr.resolve_global_ip_ids, identifier,
                                      name='global ip')
    mgr.unassign_global_ip(global_ip_id)
353530
async def on_request(
        self,
        domain,
        address,
        identity,
        mechanism,
        credentials,
    ):
        
        logger.debug(
            "Request in domain %s for %s (%r): %r (%r)",
            domain,
            address,
            identity,
            mechanism,
            credentials,
        )

        user_id = None
        metadata = {}

        if self.whitelist:
            if address not in self.whitelist:
                raise ZAPAuthenticationFailure(
                    "IP address is not in the whitelist",
                )
        elif self.blacklist:
            if address in self.blacklist:
                raise ZAPAuthenticationFailure("IP address is blacklisted")

        if mechanism == b'PLAIN':
            username = credentials[0].decode('utf-8')
            password = credentials[1].decode('utf-8')
            ref_password = self.passwords.get(username)

            if not ref_password:
                raise ZAPAuthenticationFailure("No such user %r" % username)

            if password != ref_password:
                raise ZAPAuthenticationFailure(
                    "Invalid password for user %r" % username,
                )

            user_id = username

        elif mechanism == b'CURVE':
            public_key = credentials[0]

            if public_key not in self.authorized_keys:
                raise ZAPAuthenticationFailure(
                    "Unauthorized key %r" % public_key,
                )

        return user_id, metadata
261041
def _domain_event_pmwakeup_cb(conn, domain, reason, opaque):
    '''
    
    '''
    _salt_send_domain_event(opaque, conn, domain, opaque['event'], {
        'reason': 'unknown'  # currently unused
    })
104511
private void setOfflinePresences() {
        Presence packetUnavailable;
        outerloop: for (Jid user : presenceMap.keySet()) {
            Map<Resourcepart, Presence> resources = presenceMap.get(user);
            if (resources != null) {
                for (Resourcepart resource : resources.keySet()) {
                    packetUnavailable = new Presence(Presence.Type.unavailable);
                    EntityBareJid bareUserJid = user.asEntityBareJidIfPossible();
                    if (bareUserJid == null) {
                        LOGGER.warning("Can not transform user JID to bare JID: '" + user + "'");
                        continue;
                    }
                    packetUnavailable.setFrom(JidCreate.fullFrom(bareUserJid, resource));
                    try {
                        presencePacketListener.processStanza(packetUnavailable);
                    }
                    catch (NotConnectedException e) {
                        throw new IllegalStateException(
                                        "presencePacketListener should never throw a NotConnectedException when processStanza is called with a presence of type unavailable",
                                        e);
                    }
                    catch (InterruptedException e) {
                        break outerloop;
                    }
                }
            }
        }
    }
62737
function bin (argv) {
  debug('start')

  // setup config
  process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'

  var uri = process.argv[2] || 'https://localhost:3000/random_rate'
  var cert = process.argv[3] || process.env['CERT']
  var display = process.argv[4] || process.env['DISP'] || 'display'
  var mode = process.argv[5] || 'buffer'
  var user = process.argv[6] || 'http://melvincarvalho.com/#me'
  var tag = process.argv[7]
  var bufferURI = process.argv[8] || 'https://localhost/data/buffer/video/'
  root = process.argv[9] || root
  var safe = process.argv[10] || 'on'

  debug(argv)

  console.log(process.argv)
  console.log('tag', tag)
  console.log('bufferURI', bufferURI)
  console.log('webid', user)

  var config = require(__dirname + '/../config/config.js')

  getMedia(uri, cert, mode, user, safe, bufferURI).then(function (row) {
    var uri = row.uri
    var cacheURI = row.cacheURI
    var displayURI = cacheURI || uri
    var cmd = display + ' ' + displayURI

    debug('cmd', cmd)
    debug('row', row)
    exec(cmd)
    var params = { cacheURI: cacheURI }
    params.reviewer = user
    updateLastSeen(params, config)
  }).catch(function (err) {
    console.error(err)
  })
}
67741
def process_raw_data(cls, raw_data):
        """"""
        properties = raw_data.get("properties", {})

        raw_content = properties.get("ipConfiguration", None)
        if raw_content is not None:
            resource = Resource.from_raw_data(raw_content)
            properties["ipConfiguration"] = resource

        return super(PublicIPAddresses, cls).process_raw_data(raw_data)
192355
def cli(env, identifier, price=False, guests=False):
    """"""
    dhost = SoftLayer.DedicatedHostManager(env.client)

    table = formatting.KeyValueTable(['name', 'value'])
    table.align['name'] = 'r'
    table.align['value'] = 'l'

    result = dhost.get_host(identifier)
    result = utils.NestedDict(result)

    table.add_row(['id', result['id']])
    table.add_row(['name', result['name']])
    table.add_row(['cpu count', result['cpuCount']])
    table.add_row(['memory capacity', result['memoryCapacity']])
    table.add_row(['disk capacity', result['diskCapacity']])
    table.add_row(['create date', result['createDate']])
    table.add_row(['modify date', result['modifyDate']])
    table.add_row(['router id', result['backendRouter']['id']])
    table.add_row(['router hostname', result['backendRouter']['hostname']])
    table.add_row(['owner', formatting.FormattedItem(
        utils.lookup(result, 'billingItem', 'orderItem', 'order', 'userRecord', 'username') or formatting.blank(),)])

    if price:
        total_price = utils.lookup(result,
                                   'billingItem',
                                   'nextInvoiceTotalRecurringAmount') or 0
        total_price += sum(p['nextInvoiceTotalRecurringAmount']
                           for p
                           in utils.lookup(result,
                                           'billingItem',
                                           'children') or [])
        table.add_row(['price_rate', total_price])

    table.add_row(['guest count', result['guestCount']])
    if guests:
        guest_table = formatting.Table(['id', 'hostname', 'domain', 'uuid'])
        for guest in result['guests']:
            guest_table.add_row([
                guest['id'], guest['hostname'], guest['domain'], guest['uuid']])
        table.add_row(['guests', guest_table])

    table.add_row(['datacenter', result['datacenter']['name']])

    env.fout(table)
547622
def processEnded(self, status):
        
        self.cleanup()

        if status.value.exitCode is None:
            if self._did_timeout:
                err = RuntimeError("Timeout waiting for Tor launch.")
            else:
                err = RuntimeError(
                    "Tor was killed (%s)." % status.value.signal)
        else:
            err = RuntimeError(
                "Tor exited with error-code %d" % status.value.exitCode)

        # hmmm, this log() should probably go away...not always an
        # error (e.g. .quit()
        log.err(err)
        self._maybe_notify_connected(Failure(err))
1101886
function router(sessions, nonObjTemplatelogLevel, controllers, req, res, next) {

    if (req.originalUrl.match(/amorphic\/xhr\?path\=/)) {
        if (req.body.type === 'logging') {
            processLoggingMessage(req, res);
        }
        else {
            processMessage(req, res, sessions, nonObjTemplatelogLevel, controllers);
        }
    }
    else {
        next();
    }
}
680785
function exposeThenNative(Browser, command) {
    var exposed = ['then', ucfirst(command)].join('');

    Browser.prototype[exposed] = function () {
        var args = arguments;
        ensureDriverCommand.call(this, command, 'exposeThenNative');

        this.then(function (next) {
            args = wrapArguments.call(this, args, chainAndErrorCallback, next);
            this._driver[command].apply(this._driver, args);
        });

        return this;
    };
}
1362776
def dump_netrc(self):
    """"""
    rep = ''
    for host in self.hosts.keys():
        attrs = self.hosts[host]
        rep = rep + 'machine ' + host + '\n\tlogin ' + str(attrs[0]) + '\n'
        if attrs[1]:
            rep = rep + 'account ' + str(attrs[1])
        rep = rep + '\tpassword ' + str(attrs[2]) + '\n'
    for macro in self.macros.keys():
        rep = rep + 'macdef ' + macro + '\n'
        for line in self.macros[macro]:
            rep = rep + line
        rep = rep + '\n'
    return rep