Пример #1
0
    def __init__(self):
        self.conn = None
        self.engine = None
        cfg = ConfigLoader()
        self.config = cfg.get_config()
        self.mysql_host = self.config.get('mysql_host')
        self.mysql_user = self.config.get('mysql_user')
        self.mysql_pass = self.config.get('mysql_pass')
        self.mysql_database = self.config.get('mysql_database')
        self.logging = Logger()
        conn_string = "mysql+mysqldb://{0}:{1}@{2}/{3}".format(
            self.mysql_user, self.mysql_pass, self.mysql_host,
            self.mysql_database)
        self.engine = create_engine(conn_string)
        meta = MetaData(bind=self.engine)
        self.dbconn = None

        ### Recommendations Table ###
        self.recommendations = Table(
            'product_recommendations', meta,
            Column('product_id', TEXT, nullable=False),
            Column('related_product_id', TEXT, nullable=False),
            Column('school_code', Integer, nullable=True),
            Column('subject_code', Integer, nullable=True),
            Column('class_year', Integer, nullable=True),
            Column('tag_similarity', Integer, nullable=True),
            Column('similarity', Integer, nullable=True),
            Column('similarity_score', Integer, nullable=True))
Пример #2
0
 def __init__(self):
     cfg = ConfigLoader()
     self.config = cfg.get_config()
     host = self.config.get('redis_host')
     port = self.config.get('redis_port')
     db = self.config.get('redis_db')
     self.ttl = self.config.get('redis_ttl')
     self.db = redis.StrictRedis(host=host, port=port, db=db)
Пример #3
0
 def __init__(self):
     """
         this class created for handling and dealing with check points
     """
     config_loader = ConfigLoader()
     self.config = config_loader.get_config()
     connection_pool = database_connection_pool.ConnectionPool()
     connection = connection_pool.get_connection(self.config)
     self.database = check_point_db.CheckPointDatabase(
         connection=connection)
Пример #4
0
 def __init__(self):
     """
         the loaded config file will pass into this class
     :param config:
     """
     loader = ConfigLoader()
     self.config = loader.get_config()
     self.smtp_ssl_host = self.config["mail_service.mail_host"]["email_host"][0]
     self.smtp_ssl_port = self.config["mail_service.mail_host"]["email_port"]
     self.username = self.config["mail_service.mail_host"]["email_user_name"]
     self.password = self.config["mail_service.mail_host"]["email_host_password"]
     self.sender = self.config["mail_service.mail_host"]["email_user_name"]
Пример #5
0
 def __init__(self):
     # logging.basicConfig(level=logging.DEBUG,
     #                     format='[%(levelname)s] (%(threadName)-10s) %(message)s',
     #                     )
     self.logging = Logger()
     self.repo = MongoRepository()
     self.mysql = MysqlRepository()
     cfg = ConfigLoader()
     self.config = cfg.get_config()
     self.CUTTOFF_DAYS = timedelta(
         days=self.config.get('data_days_to_analyze'))
     self.redis = RedisRepository()
     self.ar_counter = 0
     self.cb_counter = 0
    def __init__(self):
        """ Virtually private constructor. """
        if Scheduler.__instance is not None:
            raise Exception("This class is a singleton!")
        else:
            Scheduler.__instance = self
            config_loader = ConfigLoader()
            self.config = config_loader.get_config()

            executors = {
                'default': ThreadPoolExecutor(self.config['check_point.scheduler']['thread_pool_executor']),
                'processpool': ProcessPoolExecutor(self.config['check_point.scheduler']['process_pool_executor'])
            }
            job_defaults = {
                'coalesce': False,
                'max_instances': 10
            }
            self.scheduler = BackgroundScheduler(executors=executors, job_defaults=job_defaults)
            self.scheduler.start()
 def __init__(self):
     """
     """
     loader = ConfigLoader()
     self.config = loader.get_config()
     self.sender = send_module.SendModule()
Пример #8
0
    def __init__(self):
        cfg = ConfigLoader()
        self.config = cfg.get_config()

        self.SIMILARITY_CUTOFF = self.config.get('similarity_cuttoff')
        self.logging = Logger()
Пример #9
0
import json
from flask import Flask, url_for, jsonify
from config_loader import ConfigLoader

from UserRecommender import UserRecommender

rec = UserRecommender()


cfg = ConfigLoader()
config = cfg.get_config()
host = config.get('server')
port = config.get('port')

app = Flask(__name__)


@app.route('/')
def api_root():

    data = [
        {
            'id': 1,
            'title': 'Buy groceries',
            'description': u'Milk, Cheese, Pizza, Fruit, Tylenol',
            'done': False
        },
        {
            'id': 2,
            'title': u'Learn Python',
            'description': u'Need to find a good Python tutorial on the web',