Example #1
0
def prepare_reporting(mongo_addr, dbname, config_path):
    from citizendesk.common.utils import get_logger
    from citizendesk.common.dbc import mongo_dbs
    from citizendesk.feeds.config import set_config
    import citizendesk.outgest.dispatch as dispatch

    logger = get_logger()

    mongo_dbs.set_dbname(dbname)
    DbHolder = namedtuple('DbHolder', 'db')
    mongo_dbs.set_db(DbHolder(db=MongoClient(mongo_addr[0], mongo_addr[1])[mongo_dbs.get_dbname()]))

    config_data = None

    if config_path:
        try:
            cfghf = open(config_path)
            config_data = cfghf.read()
            cfghf.close()
            config_yaml = yaml.load_all(config_data)
            config_data = config_yaml.next()
            config_yaml.close()
        except:
            config_data = None
            logger.error('can not read config file: ' + str(config_path))
            return False

    dispatch.setup_blueprints(app, config_data)

    return True
Example #2
0
def prepare_reporting(mongo_addr, dbname):
    from citizendesk.common.dbc import mongo_dbs
    from citizendesk.ingest.twt.connect import twt_take

    mongo_dbs.set_dbname(dbname)
    DbHolder = namedtuple('DbHolder', 'db')
    mongo_dbs.set_db(DbHolder(db=MongoClient(mongo_addr[0], mongo_addr[1])[mongo_dbs.get_dbname()]))

    app.register_blueprint(twt_take)
Example #3
0
def prepare_reporting(mongo_addr, dbname, send_sms):
    from citizendesk.common.dbc import mongo_dbs
    from citizendesk.ingest.sms.utils import load_send_sms_config
    from citizendesk.ingest.sms.connect import setup_blueprints

    mongo_dbs.set_dbname(dbname)
    DbHolder = namedtuple('DbHolder', 'db')
    mongo_dbs.set_db(DbHolder(db=MongoClient(mongo_addr[0], mongo_addr[1])[mongo_dbs.get_dbname()]))

    load_send_sms_config(send_sms)
    setup_blueprints(app)
Example #4
0
def prepare_reporting(mongo_addr, dbname, tlds_path):
    from citizendesk.common.dbc import mongo_dbs
    from citizendesk.ingest.url.utils import set_effective_tlds
    from citizendesk.ingest.url.connect import setup_blueprints

    mongo_dbs.set_dbname(dbname)
    DbHolder = namedtuple('DbHolder', 'db')
    mongo_dbs.set_db(DbHolder(db=MongoClient(mongo_addr[0], mongo_addr[1])[mongo_dbs.get_dbname()]))

    set_effective_tlds(tlds_path)
    setup_blueprints(app)
Example #5
0
def prepare_reporting(mongo_addr, dbname):
    from citizendesk.common.dbc import mongo_dbs
    from citizendesk.ingest.twt.connect import twt_take, twt_user_take

    mongo_dbs.set_dbname(dbname)
    DbHolder = namedtuple('DbHolder', 'db')
    mongo_dbs.set_db(
        DbHolder(db=MongoClient(mongo_addr[0], mongo_addr[1])[
            mongo_dbs.get_dbname()]))

    app.register_blueprint(twt_take)
    app.register_blueprint(twt_user_take)
Example #6
0
def prepare_reporting(mongo_addr, dbname, newstwister_url):
    from citizendesk.common.dbc import mongo_dbs
    from citizendesk.feeds.config import set_config
    import citizendesk.feeds.twt.dispatch as twt_dispatch

    mongo_dbs.set_dbname(dbname)
    DbHolder = namedtuple('DbHolder', 'db')
    mongo_dbs.set_db(DbHolder(db=MongoClient(mongo_addr[0], mongo_addr[1])[mongo_dbs.get_dbname()]))

    set_config('newstwister_url', newstwister_url)

    twt_dispatch.setup_blueprints(app)
Example #7
0
def prepare_reporting(mongo_addr, dbname, newstwister_url, sms_config_path):
    from citizendesk.common.utils import get_logger
    from citizendesk.common.dbc import mongo_dbs
    from citizendesk.feeds.config import set_config
    import citizendesk.feeds.err.dispatch as err_dispatch
    import citizendesk.feeds.any.dispatch as any_dispatch
    import citizendesk.feeds.img.dispatch as img_dispatch
    import citizendesk.feeds.twt.dispatch as twt_dispatch
    import citizendesk.feeds.sms.dispatch as sms_dispatch

    logger = get_logger()

    mongo_dbs.set_dbname(dbname)
    DbHolder = namedtuple('DbHolder', 'db')
    mongo_dbs.set_db(
        DbHolder(db=MongoClient(mongo_addr[0], mongo_addr[1])[
            mongo_dbs.get_dbname()]))

    set_config('newstwister_url', newstwister_url)

    if sms_config_path:
        try:
            shf = open(sms_config_path)
            sms_config_data = shf.read()
            shf.close()
            sms_yaml = yaml.load_all(sms_config_data)
            sms_config = sms_yaml.next()
            sms_yaml.close()
        except:
            logger.error('can not read sms config file: ' +
                         str(sms_config_path))
            return False

        if ('gateway_api' in sms_config) and sms_config['gateway_api']:
            set_config('sms_gateway_api', sms_config['gateway_api'])
        if ('gateway_url' in sms_config) and sms_config['gateway_url']:
            set_config('sms_gateway_url', sms_config['gateway_url'])
        if ('gateway_key' in sms_config) and sms_config['gateway_key']:
            set_config('sms_gateway_key', sms_config['gateway_key'])
        if ('allowed_ips' in sms_config) and sms_config['allowed_ips']:
            set_config('sms_allowed_ips', sms_config['allowed_ips'])

    err_dispatch.setup_blueprints(app)
    any_dispatch.setup_blueprints(app)
    img_dispatch.setup_blueprints(app)
    twt_dispatch.setup_blueprints(app)
    sms_dispatch.setup_blueprints(app)

    return True
Example #8
0
def prepare_reporting(mongo_addr, dbname, newstwister_url, sms_config_path):
    from citizendesk.common.utils import get_logger
    from citizendesk.common.dbc import mongo_dbs
    from citizendesk.feeds.config import set_config
    import citizendesk.feeds.err.dispatch as err_dispatch
    import citizendesk.feeds.any.dispatch as any_dispatch
    import citizendesk.feeds.img.dispatch as img_dispatch
    import citizendesk.feeds.twt.dispatch as twt_dispatch
    import citizendesk.feeds.sms.dispatch as sms_dispatch

    logger = get_logger()

    mongo_dbs.set_dbname(dbname)
    DbHolder = namedtuple('DbHolder', 'db')
    mongo_dbs.set_db(DbHolder(db=MongoClient(mongo_addr[0], mongo_addr[1])[mongo_dbs.get_dbname()]))

    set_config('newstwister_url', newstwister_url)

    if sms_config_path:
        try:
            shf = open(sms_config_path)
            sms_config_data = shf.read()
            shf.close()
            sms_yaml = yaml.load_all(sms_config_data)
            sms_config = sms_yaml.next()
            sms_yaml.close()
        except:
            logger.error('can not read sms config file: ' + str(sms_config_path))
            return False

        if ('gateway_api' in sms_config) and sms_config['gateway_api']:
            set_config('sms_gateway_api', sms_config['gateway_api'])
        if ('gateway_url' in sms_config) and sms_config['gateway_url']:
            set_config('sms_gateway_url', sms_config['gateway_url'])
        if ('gateway_key' in sms_config) and sms_config['gateway_key']:
            set_config('sms_gateway_key', sms_config['gateway_key'])
        if ('allowed_ips' in sms_config) and sms_config['allowed_ips']:
            set_config('sms_allowed_ips', sms_config['allowed_ips'])

    err_dispatch.setup_blueprints(app)
    any_dispatch.setup_blueprints(app)
    img_dispatch.setup_blueprints(app)
    twt_dispatch.setup_blueprints(app)
    sms_dispatch.setup_blueprints(app)

    return True