Example #1
0
    def on_post(self, req, resp):
        try:
            doc = req.context['doc']
            redis = RedisWrapper()
            key = redis.store_message(doc)
        except KeyError:
			raise falcon.HTTPBadRequest('Missing body','A json body must be submitted.')

        resp.status = falcon.HTTP_200
        resp.body = '{"key": "'+str(key)+'"}'
Example #2
0
def main():
    redis_wrapper = RedisWrapper()
    subscriber_obj = redis_wrapper.subscriber_obj()
    subscriber_obj.subscribe('to_redis')

    print("Hearing messages from ROS2...")

    for message in subscriber_obj.listen():
        if message['type'] == 'message':
            data = from_json_to_dict(message['data'].decode('utf-8'))
            print("Heard: " + str(data))
            redis_wrapper.publish("from_redis", "I heard it (from HOST)")
Example #3
0
class Manager(object):
    '''
    Manager Class - > Wrapper for the server/user to save or fetch data from redis
    '''
    def __init__(self, file_date=None):
        self.redis = RedisWrapper()
        self.downloader = Downloader(file_date)

    def download_and_save_bhavcopy(self):
        native_data = self.downloader.serialize()
        self.redis.save_csv(native_data)

    def filter_results(self, searchstr, page_size, page_number):
        return self.redis.filter(searchstr,
                                 page_number=page_number,
                                 page_size=page_size)
#!/usr/bin/python

import sys, os, json, inspect
from redis_wrapper import RedisWrapper

port = 9000
queue = RedisWrapper("example_queue", host="localhost", port=port, db=0)

queue.put(9)
queue.put(8)
queue.put(7)
queue.put(6)
queue.put(5)


Example #5
0
 def on_get(self, req, resp, key):
 	redis = RedisWrapper()
 	message = redis.get_message(key)
     resp.status = falcon.HTTP_200
     resp.body = message
#!/usr/bin/python

import sys, os, json, inspect
from redis_wrapper import RedisWrapper

port = 9000
queue = RedisWrapper("example_queue", host="localhost", port=port, db=0)

while True:
    print "Got this: " + str(queue.get(True))


Example #7
0
#!/usr/bin/python

import sys, os, json, inspect
from redis_wrapper import RedisWrapper

port = 6000
db = int(os.getenv("ENV_REDIS_DB_ID", 0))
redis_pw = os.getenv("ENV_REDIS_PASSWORD",
                     "")  # if set to empty string use password=None

if str(redis_pw) == "":
    redis_pw = None

queue = RedisWrapper("example_queue",
                     host="localhost",
                     port=port,
                     db=int(db),
                     password=redis_pw)

queue.put(9)
queue.put(8)
queue.put(7)
queue.put(6)
queue.put(5)
Example #8
0
 def __init__(self, file_date=None):
     self.redis = RedisWrapper()
     self.downloader = Downloader(file_date)
Example #9
0
#!/usr/bin/python

import sys, os, json, inspect
from redis_wrapper import RedisWrapper

port = 6000
db = int(os.getenv("ENV_REDIS_DB_ID", 0))
redis_pw = os.getenv("ENV_REDIS_PASSWORD",
                     "")  # if set to empty string use password=None

if str(redis_pw) == "":
    redis_pw = None

queue = RedisWrapper("example_queue",
                     host="localhost",
                     port=port,
                     db=int(db),
                     password=redis_pw)

while True:
    print "Got this: " + str(queue.get(True))