Esempio n. 1
0
class Application(web.Application):

	settings = {
		'aes_key': '02B6111770695324',
		'delimiter': '\n',
		'timeout': 300,
		# controller start message
		'controller_start': '\xff\xff\xff\xff\xff\xff\xff\xff',
		'response_fail': '\xee\xee\xee\xee\xee\xee\xee\xee',
		'response_success': '\xbb\xbb\xbb\xbb\xbb\xbb\xbb\xbb',
		'debug': False
	}

	# Connect to redis device_cache
	d = {'host': '127.0.0.1', 'port': 6379, 'db': 0}
	devices_cache = cache.Cache(**d)

	# Connect to access_token_cache.
	d = {'host': '127.0.0.1', 'port': 6379, 'db': 2}
	access_token_cache = cache.Cache(**d)

	# Connect to database bikedb.
	models = models

	def __init__(self):
		super(Application, self).__init__(url_patterns, **settings)
Esempio n. 2
0
	def __init__(self, init_params, data):
		
		self.config = init_params['config']
		self.app_mode = init_params['app_mode']
		self.project_directory = init_params['project_directory']
		self.cache = cache.Cache( self.config.get("CACHE", "host"), int(self.config.get("CACHE", "port")) )
		self.math = math.Math()
		self.maps = self.generate_maps()
		self.data = data
Esempio n. 3
0
class Application(web.Application):

	cache = cache
	user_session = cache.Cache(host='localhost', port=6379, db=3)

	models = models

	def __init__(self):
		super(Application, self).__init__(url_patterns, **settings)
Esempio n. 4
0
    def __init__(self, init_params, data, image_location_map):

        self.config = init_params['config']
        self.app_mode = init_params['app_mode']
        self.project_directory = init_params['project_directory']
        self.cache = cache.Cache(self.config.get("CACHE", "host"),
                                 int(self.config.get("CACHE", "port")))
        self.math = math.Math()
        self.data = data
        self.image_location_map = image_location_map
class Application(web.Application):
	cache_cfg = {
		'host': settings.get('redis_host'),
		'port': settings.get('redis_port'),
		'db': settings.get('redis_db')
	}
	access_token_cache = cache.Cache(**cache_cfg)
	models = models

	def __init__(self):
		super(Application, self).__init__(url_patterns, **settings)
Esempio n. 6
0
    def __init__(self, init_params):

        self.config = init_params['config']
        self.app_mode = init_params['app_mode']
        self.project_directory = init_params['project_directory']
        self.cache = cache.Cache(self.config.get("CACHE", "host"),
                                 int(self.config.get("CACHE", "port")))
        self.math = math.Math()

        self.user_data = (scipy.sparse.load_npz(
            self.project_directory +
            self.config.get("PREPROCESSED-DATA", "user_features"))).todense()
        self.image_data = (scipy.sparse.load_npz(
            self.project_directory +
            self.config.get("PREPROCESSED-DATA", "image_features"))).todense()
        self.location_data = (scipy.sparse.load_npz(
            self.project_directory +
            self.config.get("PREPROCESSED-DATA", "location_features"))
                              ).todense()

        self.visual_descriptors = self.generate_visual_descriptors_map()
Esempio n. 7
0
    async def prep(self):
        print(f"\n > All shards ready, finishing preperations")

        self.ftime.set()
        print(f" > Session started at {self.ftime.start}\n")

        db.checkguilds(self.guilds)

        self.premium = await self.get_premium()
        self.cache = cache.Cache(self.settings.devs, self.premium)

        for command in cm.commands:
            self.cache.cooldowns.add(command, tuple(cm.commands[command][3:5]))
        for command in cm.devcmds:
            self.cache.cooldowns.add(command, (0, 0))
        print(" > Finished setting up cooldowns\n")

        await self.change_presence(status=discord.Status.online,
                                activity=discord.Game(name="'FBot help'"))

        print(f" > Bot is ready")
        self.dispatch("bot_ready")
def cache_search(name, num):
    from lib.encoder import MongoEncoder

    c = cache.Cache(master=True, db=config.Cache.searchdb)

    if c.llen(name) > 0:
        return

    print 'Slave [ %d ] genrate search cache %s' % (num, name)

    imgids = __get_all_image_by_name(name)

    for i in imgids:
        try:
            _id = objectid.ObjectId(i)
            img = mongo.image.find_one({'_id': _id})
            if img:
                c.rpush(name, json.dumps(
                    img, cls=MongoEncoder)
                    )
        except:
            raise
            continue
    print 'Slave [ %d ] generate %s finish...' % (num, name)
Esempio n. 9
0
def flush_cache():
    c = cache.Cache(master=True)
    c.flush()