diff --git a/src/eddn/Gateway.py b/src/eddn/Gateway.py index 5534aeb..9d7bcb5 100644 --- a/src/eddn/Gateway.py +++ b/src/eddn/Gateway.py @@ -213,7 +213,7 @@ class MalformedUploadError(Exception): def main(): loadConfig() configure() - run(host='0.0.0.0', port=Settings.GATEWAY_HTTP_PORT, server='gevent') + run(host=Settings.GATEWAY_HTTP_BIND_ADDRESS, port=Settings.GATEWAY_HTTP_PORT, server='gevent') if __name__ == '__main__': diff --git a/src/eddn/conf/Settings.py b/src/eddn/conf/Settings.py index c4cafcf..f898ef5 100644 --- a/src/eddn/conf/Settings.py +++ b/src/eddn/conf/Settings.py @@ -31,7 +31,8 @@ class _Settings(object): # Gateway settings ############################################################################### - GATEWAY_HTTP_PORT = 8080 + GATEWAY_HTTP_BIND_ADDRESS = "127.0.0.1" + GATEWAY_HTTP_PORT = 8081 GATEWAY_SENDER_BINDINGS = ["tcp://*:8500"] diff --git a/src/eddn/core/DuplicateMessages.py b/src/eddn/core/DuplicateMessages.py index 039f1c1..1d16919 100644 --- a/src/eddn/core/DuplicateMessages.py +++ b/src/eddn/core/DuplicateMessages.py @@ -1,14 +1,13 @@ # coding: utf8 +import hashlib +import re +import simplejson +import zlib from datetime import datetime, timedelta +from eddn.conf.Settings import Settings from threading import Lock, Thread from time import sleep -import hashlib -import zlib -import re - -import simplejson -from eddn.conf.Settings import Settings, loadConfig class DuplicateMessages(Thread): diff --git a/src/eddn/core/StatsCollector.py b/src/eddn/core/StatsCollector.py index fdf8ed7..9ce7f05 100644 --- a/src/eddn/core/StatsCollector.py +++ b/src/eddn/core/StatsCollector.py @@ -13,18 +13,17 @@ class StatsCollector(Thread): you choose, up to one hour. ''' - max_minutes = 60 - - current = {} - history = {} - - lock = Lock() - - starttime = 0 - def __init__(self): super(StatsCollector, self).__init__() self.daemon = True + self.max_minutes = 60 + + self.current = {} + self.history = {} + + self.lock = Lock() + + self.starttime = 0 def run(self): self.starttime = datetime.utcnow() @@ -44,12 +43,6 @@ class StatsCollector(Thread): else: self.current[key] += 1 - def getInboundCount(self, minutes): - return sum(islice(self.inboundHistory, 0, min(minutes, self.max_minutes))) - - def getOutboundCount(self, minutes): - return sum(islice(self.outboundHistory, 0, min(minutes, self.max_minutes))) - def getCount(self, key, minutes): if key in self.history: return sum(islice(self.history[key], 0, min(minutes, self.max_minutes))) diff --git a/src/eddn/core/tests/TestStatsCollector.py b/src/eddn/core/tests/TestStatsCollector.py new file mode 100644 index 0000000..d4330b1 --- /dev/null +++ b/src/eddn/core/tests/TestStatsCollector.py @@ -0,0 +1,17 @@ +import unittest + +from eddn.core.StatsCollector import StatsCollector +from time import sleep + + +class Test(unittest.TestCase): + + def testStatsCollectorTally(self): + print "This test will take about 60 seconds to run!" + statsCollector = StatsCollector() + statsCollector.start() + + self.assertEqual(0, statsCollector.getCount("test", 1)) + statsCollector.tally("test") + sleep(61) + self.assertEqual(1, statsCollector.getCount("test", 1)) diff --git a/src/eddn/core/tests/__init__.py b/src/eddn/core/tests/__init__.py new file mode 100644 index 0000000..e69de29