def create_application(config_path: Optional[str] = None):
    """
    Creates the flask application

    :param config_path: the path to the configuration
    :return: a Flask app
    """
    if not config_path:
        config_path = DEFAULT_CONFIG_FILE
    config = load_config(config_path)
    set_statistics_database(config.statistics_database)
    controller = Controller(config.auth_server,config.media_server,
                            config.video_database,config.friend_database,
                            config.statistics_database,
                            config.notifications_database)
    return create_application_with_controller(controller)
Ejemplo n.º 2
0
import pdb
import argparse

from config.load_config import load_config
load_config()


class CommandOptions:
    dmcheckuserscreenname = None


class Migration:
    def __init__(self):
        #tested
        self.cmd_options = CommandOptions()

    def read_command(self):
        #tested
        parser = argparse.ArgumentParser(description='Migration tool')
        parser.add_argument(
            '--dmcheckuserscreenname',
            metavar="Screen name of DM user",
            help=
            'DM check  service old data migration to service based approach')
        args = parser.parse_args()
        self.cmd_options.dmcheckuserscreenname = args.dmcheckuserscreenname

    def handle_migration(self):
        #tested
        if self.cmd_options.dmcheckuserscreenname:
            self.__handle_dmcheck_migration()
Ejemplo n.º 3
0
def main(arg):
    config = load_config(arg.config)
    Server(config, arg.flag)
Ejemplo n.º 4
0
        level=logging.INFO,
        format='%(asctime)s.%(msecs)03d %(levelname)s %(module)s - %(funcName)s: %(message)s',
        datefmt='%Y-%m-%d %H:%M:%S',
    )

    ack_process = AckProcess(ACK_LISTENING_PORT, os.getpid())
    ack_process_aux = Process(target=ack_process.run)
    ack_process_aux.start()

    parser = argparse.ArgumentParser(description='Rabbit producer consumer')
    parser.add_argument('--config', help="The config file to use", required=True)
    args = parser.parse_args()
    config = load_config(args.config,
                         {'date_to_weekday': date_to_weekday,
                          'leq_than_50': leq_than_50,
                          'leq_than_5': leq_than_5,
                          'equal_to_5': equal_to_5,
                          'is_true': is_true,
                          'leq_than_1': leq_than_1})
    logger = logging.getLogger()
    consumer = RabbitQueueConsumerProducer(host=config.host, consume_queue=config.consume_from,
                                           response_queues=config.produce_to,
                                           messages_to_group=config.messages_to_group,
                                           callable_commiter=config.message_pipeline, logger=logger,
                                           publisher_sharding=config.publisher_sharding)
    while True:
        try:
            consumer()
        except AMQPConnectionError:
            sleep(2)
            logger.info("Retrying connection to rabbit...")
Ejemplo n.º 5
0
def __init_program():
    print("CWD is {}".format(os.getcwd()))
    abspath = os.path.abspath(__file__)
    dname = os.path.dirname(abspath)
    os.chdir(dname)
    print("After change, CWD is {}".format(os.getcwd()))


__init_program()
'''
User defined modules
'''
from config.load_config import load_config
config_file_name = 'tweet_env.py'
load_config(config_file_name)

dep_check = os.getenv("DEPENDENCY_CHECK", "True")
if dep_check.lower() == "true":
    from installer import dependency_check

from libs.cypher_store import TweetCypherStoreIntf
#from file_store import DMFileStoreIntf
from libs.twitter_errors import TwitterRateLimitError, TwitterUserNotFoundError

from libs.twitter_access import fetch_tweet_info, get_reponse_header
from libs.twitter_logging import logger
from libs.tweet_filter_handler import TweetFilterHandler


class TweetsFetcher:
Ejemplo n.º 6
0
                            help='daemon mode',
                            default='yes')
        results = parser.parse_args()
        self.filepath = results.filepath
        self.env = results.env
        self.daemon = common.isTrue(results.daemon)


argsHandler = ArgsHandler()
argsHandler.get_args()
'''
User defined modules
'''
from config.load_config import load_config

load_config(argsHandler.env)

dep_check = os.getenv("DEPENDENCY_CHECK", "False")
if dep_check.lower() == "true":
    from installer import dependency_check

from libs.cypher_store import TweetCypherStoreIntf
#from file_store import DMFileStoreIntf
from libs.twitter_errors import TwitterRateLimitError, TwitterUserNotFoundError

from libs.twitter_access import fetch_tweet_info, get_reponse_header
from libs.twitter_logging import logger
from libs.tweet_filter_handler import TweetFilterHandler

from libs.fetcher_query_db_intf import TweetFetchQueryIntf