Example #1
0
 def __init__(self, persistent=True):
     self.persistent = persistent
     self.agents = SortedCollection(key=lambda x: x.url.netloc)
     self.pool = HTTPConnectionPool(reactor)
     self.pool.maxPersistentPerHost = getattr(
         settings, 'DTX_WEB_DEFER_MAX_PERSISTENT_PER_HOST', 8)
     self.pool.cachedConnectionTimeout = getattr(
         settings, 'DTX_WEB_DEFER_CONNECT_TIMEOUT', 10)
Example #2
0
 def __init__(self, get_item_defer_callable, seconds=120):
     self.get_item_defer_callable = get_item_defer_callable
     self.seconds = seconds
     self.cache = {}
     self.keys = SortedCollection([], key=lambda item: item['ts'])
     self.update_requests = {}
Example #3
0
 def __init__(self):
     #WampClientProtocol.__init__(self)
     self.evalSessions = SortedCollection(key=lambda x: x.id)
Example #4
0
from django.utils import translation
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext
from django.utils.translation import ugettext_noop
from django.utils.translation import get_language

from django.contrib.staticfiles import finders

from dtx.utils.snippets.sorted_collection import SortedCollection
from dtx.memcache import client as dtx_memcache

from dtx.core import logger
log = logger.log(__name__)

static_files_by_path = SortedCollection(key=lambda x: x.path)


class StaticFileInfo:
    def __init__(self, path, body_digest, mime_type, mime_charset):
        self.path = path
        self.path_digest = hashlib.md5(path).hexdigest()
        self.body_digest = body_digest
        self.mime_type = mime_type
        self.mime_charset = mime_charset
        self.mtime = os.stat(path).st_mtime

    @classmethod
    def create(cls, path, body_digest, mime_type, mime_charset):
        global static_files_by_path
        info = cls(path, body_digest, mime_type, mime_charset)
Example #5
0
from twisted.internet.defer import inlineCallbacks, returnValue, Deferred
from twisted.internet import task
from twisted.internet import reactor

from django.conf import settings

from dtx.utils.snippets.sorted_collection import SortedCollection

from dtx.core import logger
log = logger.log(__name__)

##############################################################################################################################
#
##############################################################################################################################

wamp_connections = SortedCollection(key=lambda x: x.uuid)
wamp_connection_uuid = 1

##############################################################################################################################
#
##############################################################################################################################


class ServerFactory(WampServerFactory):
    def __init__(self, uri, apps, debug=False):
        WampServerFactory.__init__(self, uri, debug)
        self.apps = []
        for app in apps:
            if (isinstance(app, (str))):
                mod = import_module(app)
            else:
Example #6
0
 def __init__(self):
     self.configs = SortedCollection(key=lambda x: x.urlconf)
     log.msg(u'Registering static web sites')
     for address, urlconf in getattr(settings, 'DTX_WEB_REMOTE_SITES', []):
         log.msg(u'Registering {} for {}'.format(address, urlconf))
         self.addWorker(address, urlconf)
Example #7
0
 def __init__(self, urlconf):
     self.urlconf = urlconf
     self.workers = SortedCollection(key=lambda x: x.address)
     self.index = 0