class Controller(object):
    """
    Controller controls sequence from downloadnig to parsing.
    As default for widget logger.
    """
    def __init__(self, ):
        """
        init
        """

        logger = logging.getLogger("Controller")
        logger.setLevel(logging.INFO)
        logging.basicConfig()
        self.logger = logger

        self.mixs_log_importer = MixsLogImporter()
        self.power_sampler_log_importer = PowerSamplerLogImporter()
        self.user_all_logs_converter = UserAllLogsConverter()
        self.user_all_logs_summary_converter = UserAllLogsSummaryConverter()
        self.all_users_all_logs_summary_converter = AllUsersAllLogsSummaryConverter(
        )
        self.app_all_logs_converter = AppAllLogsConverter()
        self.app_all_logs_summary_converter = AppAllLogsSummaryConverter()
        self.all_apps_all_logs_summary_converter = AllAppsAllLogsSummaryConverter(
        )
        self.transporter = MixsLogTransporter()

        pass

    def control(self, ):
        """
        control
        """

        self.logger.info("controll starts")
        st = time.time()

        #self.power_sampler_log_importer.imports()

        self.mixs_log_importer.imports()
        self.user_all_logs_converter.convert()
        self.user_all_logs_summary_converter.convert()
        self.all_users_all_logs_summary_converter.convert()

        self.app_all_logs_converter.convert()
        self.app_all_logs_summary_converter.convert()
        self.all_apps_all_logs_summary_converter.convert()

        self.transporter.transport()

        et = time.time()
        self.logger.info("total time: %f[s]" % (et - st))
        self.logger.info("controll finished")
        pass

    pass
class Controller(object):
    """
    Controller controls sequence from downloadnig to parsing.
    As default for widget logger.
    """
    
    def __init__(self, ):
        """
        init
        """

        logger = logging.getLogger("Controller")
        logger.setLevel(logging.INFO)
        logging.basicConfig()
        self.logger = logger
        
        self.mixs_log_importer = MixsLogImporter()
        self.power_sampler_log_importer = PowerSamplerLogImporter()
        self.user_all_logs_converter = UserAllLogsConverter()
        self.user_all_logs_summary_converter = UserAllLogsSummaryConverter()
        self.all_users_all_logs_summary_converter = AllUsersAllLogsSummaryConverter()
        self.app_all_logs_converter = AppAllLogsConverter()
        self.app_all_logs_summary_converter = AppAllLogsSummaryConverter()
        self.all_apps_all_logs_summary_converter = AllAppsAllLogsSummaryConverter()
        self.transporter = MixsLogTransporter()

        pass
    
    def control(self, ):
        """
        control
        """

        self.logger.info("controll starts")
        st = time.time()

        #self.power_sampler_log_importer.imports()

        self.mixs_log_importer.imports()
        self.user_all_logs_converter.convert()
        self.user_all_logs_summary_converter.convert()
        self.all_users_all_logs_summary_converter.convert()
        
        self.app_all_logs_converter.convert()
        self.app_all_logs_summary_converter.convert()
        self.all_apps_all_logs_summary_converter.convert()

        self.transporter.transport()

        et = time.time()
        self.logger.info("total time: %f[s]" % (et-st))
        self.logger.info("controll finished")
        pass

    pass
class LauncherLogController(Controller):
    """
    Launcher Log Controller controls sequence from downloadnig to parsing, for launchger log.
    """

    raw_log_path = "/data/mixs_launcher_logs/raw"
    json_usrs_log_path = "/data/mixs_launcher_logs/json"
    local_data_path = "/data/mixs_launcher_logs"

    file_filters = ["VALauncherLogger"]
    
    def __init__(self, ):
        """
        init
        """
        super(LauncherLogController, self).__init__()
        
        logger = logging.getLogger("LauncherLogController")
        logger.setLevel(logging.INFO)
        logging.basicConfig()
        self.logger = logger
        
        self.mixs_log_importer = MixsLogImporter(raw_log_path = self.raw_log_path,
                                                 json_usrs_log_path = self.json_usrs_log_path,
                                                 file_filters = self.file_filters
                                                 )
        self.user_all_logs_converter = UserAllLogsConverter(json_usrs_log_path = self.json_usrs_log_path)
        self.transporter = MixsLogTransporter(local_data_path = self.local_data_path)

        pass
    
    def control(self, ):
        """
        control
        """

        self.logger.info("controll starts")
        st = time.time()

        # import
        self.mixs_log_importer.imports()

        # convert
        self.user_all_logs_converter.convert()

        # transport
        self.transporter.transport()

        et = time.time()
        self.logger.info("total time: %f[s]" % (et-st))
        self.logger.info("controll finished")
        pass

    pass
    def __init__(self, ):
        """
        init
        """
        super(LauncherLogController, self).__init__()
        
        logger = logging.getLogger("LauncherLogController")
        logger.setLevel(logging.INFO)
        logging.basicConfig()
        self.logger = logger
        
        self.mixs_log_importer = MixsLogImporter(raw_log_path = self.raw_log_path,
                                                 json_usrs_log_path = self.json_usrs_log_path,
                                                 file_filters = self.file_filters
                                                 )
        self.user_all_logs_converter = UserAllLogsConverter(json_usrs_log_path = self.json_usrs_log_path)
        self.transporter = MixsLogTransporter(local_data_path = self.local_data_path)

        pass
    def __init__(self, ):
        """
        init
        """

        logger = logging.getLogger("Controller")
        logger.setLevel(logging.INFO)
        logging.basicConfig()
        self.logger = logger

        self.mixs_log_importer = MixsLogImporter()
        self.power_sampler_log_importer = PowerSamplerLogImporter()
        self.user_all_logs_converter = UserAllLogsConverter()
        self.user_all_logs_summary_converter = UserAllLogsSummaryConverter()
        self.all_users_all_logs_summary_converter = AllUsersAllLogsSummaryConverter(
        )
        self.app_all_logs_converter = AppAllLogsConverter()
        self.app_all_logs_summary_converter = AppAllLogsSummaryConverter()
        self.all_apps_all_logs_summary_converter = AllAppsAllLogsSummaryConverter(
        )
        self.transporter = MixsLogTransporter()

        pass
    def __init__(self, ):
        """
        init
        """

        logger = logging.getLogger("Controller")
        logger.setLevel(logging.INFO)
        logging.basicConfig()
        self.logger = logger
        
        self.mixs_log_importer = MixsLogImporter()
        self.power_sampler_log_importer = PowerSamplerLogImporter()
        self.user_all_logs_converter = UserAllLogsConverter()
        self.user_all_logs_summary_converter = UserAllLogsSummaryConverter()
        self.all_users_all_logs_summary_converter = AllUsersAllLogsSummaryConverter()
        self.app_all_logs_converter = AppAllLogsConverter()
        self.app_all_logs_summary_converter = AppAllLogsSummaryConverter()
        self.all_apps_all_logs_summary_converter = AllAppsAllLogsSummaryConverter()
        self.transporter = MixsLogTransporter()

        pass