Ejemplo n.º 1
0
    def testConnectTimeout(self):
        # Test connect() timeout
        _timeout = 0.001
        self.sock.settimeout(_timeout)

        # If we are too close to www.python.org, this test will fail.
        # Pick a host that should be farther away.
        if (socket.getfqdn().split('.')[-2:] == ['python', 'org'] or
            socket.getfqdn().split('.')[-2:-1] == ['xs4all']):
            self.addr_remote = ('tut.fi', 80)

        _t1 = time.time()
        self.failUnlessRaises(socket.error, self.sock.connect,
                self.addr_remote)
        _t2 = time.time()

        _delta = abs(_t1 - _t2)
        self.assert_(_delta < _timeout + self.fuzz,
                     "timeout (%g) is more than %g seconds more than expected (%g)"
                     %(_delta, self.fuzz, _timeout))
Ejemplo n.º 2
0
 def testHostnameRes(self):
     # Testing hostname resolution mechanisms
     hostname = socket.gethostname()
     try:
         ip = socket.gethostbyname(hostname)
     except socket.error:
         # Probably name lookup wasn't set up right; skip this test
         return
     self.assert_(ip.find('.') >= 0, "Error resolving host to ip.")
     try:
         hname, aliases, ipaddrs = socket.gethostbyaddr(ip)
     except socket.error:
         # Probably a similar problem as above; skip this test
         return
     all_host_names = [hostname, hname] + aliases
     fqhn = socket.getfqdn(ip)
     if not fqhn in all_host_names:
         self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names)))
Ejemplo n.º 3
0
 def testHostnameRes(self):
     # Testing hostname resolution mechanisms
     hostname = socket.gethostname()
     try:
         ip = socket.gethostbyname(hostname)
     except socket.error:
         # Probably name lookup wasn't set up right; skip this test
         return
     self.assert_(ip.find('.') >= 0, "Error resolving host to ip.")
     try:
         hname, aliases, ipaddrs = socket.gethostbyaddr(ip)
     except socket.error:
         # Probably a similar problem as above; skip this test
         return
     all_host_names = [hostname, hname] + aliases
     fqhn = socket.getfqdn(ip)
     if not fqhn in all_host_names:
         self.fail(
             "Error testing host resolution mechanisms. (fqdn: %s, all: %s)"
             % (fqhn, repr(all_host_names)))
Ejemplo n.º 4
0
 def address_string(self):
     host, port = self.client_address[:2]
     return socket.getfqdn(host)
Ejemplo n.º 5
0
 def server_bind(self):
     """Override server_bind to store the server name."""
     SocketServer.TCPServer.server_bind(self)
     host, port = self.socket.getsockname()[:2]
     self.server_name = socket.getfqdn(host)
     self.server_port = port
Ejemplo n.º 6
0
    app.config.setdefault('REDIS_PASSWORD', None)
    return redis.Redis(host=app.config['REDIS_HOST'],
                       port=app.config['REDIS_PORT'],
                       db=app.config['REDIS_DB'],
                       password=app.config['REDIS_PASSWORD'])


app = Flask(__name__, instance_relative_config=False)

app.url_map.converters['objectid'] = ObjectIDConverter

app.config["RETHINKDB_HOST"] = "127.0.0.1"
app.config["RETHINKDB_PORT"] = "28015"
app.config["RETHINKDB_AUTH"] = "password"
app.config["RETHINKDB_DB"] = "stalker"
app.config['LOCAL_CID'] = getfqdn()
app.config['GLOBAL_CLUSTERS'] = None
app.config['REMOTE_TIMEOUT'] = 2
app.config['REGISTER_KEY'] = 'itsamario'
app.config['API_KEY'] = 'something'
app.config['SECRET_KEY'] = 'SuperSecretDevKeyChangeMe!'
app.config['THEMES'] = [
    'cosmo', 'cerulean', 'cyborg', 'slate', 'spacelab', 'united', 'flatly'
]
app.config['CACHE_TTL'] = 10
app.config['GRAPHITE_ENABLE'] = False
app.config['GRAPHITE_HOST'] = 'http://localhost/'
app.config['LOG_FILE'] = '/var/log/stalker/stalkerweb.log'
app.config['LOG_NAME'] = 'stalkerweb'
app.config['LOG_COUNT'] = 7
Ejemplo n.º 7
0
 def server_bind(self):
     """Override server_bind to store the server name."""
     socketserver.TCPServer.server_bind(self)
     host, port = self.server_address[:2]
     self.server_name = socket.getfqdn(host)
     self.server_port = port
Ejemplo n.º 8
0
    app.config.setdefault('REDIS_PASSWORD', None)
    return redis.Redis(host=app.config['REDIS_HOST'],
                       port=app.config['REDIS_PORT'],
                       db=app.config['REDIS_DB'],
                       password=app.config['REDIS_PASSWORD'])

app = Flask(__name__, instance_relative_config=False)

app.url_map.converters['objectid'] = ObjectIDConverter


app.config["RETHINKDB_HOST"] = "127.0.0.1"
app.config["RETHINKDB_PORT"] = "28015"
app.config["RETHINKDB_AUTH"] = "password"
app.config["RETHINKDB_DB"] = "stalker"
app.config['LOCAL_CID'] = getfqdn()
app.config['GLOBAL_CLUSTERS'] = None
app.config['REMOTE_TIMEOUT'] = 2
app.config['REGISTER_KEY'] = 'itsamario'
app.config['API_KEY'] = 'something'
app.config['SECRET_KEY'] = 'SuperSecretDevKeyChangeMe!'
app.config['THEMES'] = ['cosmo', 'cerulean', 'cyborg', 'slate', 'spacelab',
                        'united', 'flatly']
app.config['CACHE_TTL'] = 10
app.config['GRAPHITE_ENABLE'] = False
app.config['GRAPHITE_HOST'] = 'http://localhost/'
app.config['LOG_FILE'] = '/var/log/stalker/stalkerweb.log'
app.config['LOG_NAME'] = 'stalkerweb'
app.config['LOG_COUNT'] = 7

app.config.from_envvar('STALKERWEB_CONFIG', silent=True)
Ejemplo n.º 9
0
 def __init__(self, port=6667, listen='0.0.0.0'):
     self.port = port
     self.listen = listen
     self.host = socket.getfqdn(listen)
     self.startup = datetime.datetime.utcnow()