# Path: scripts/pfp_batch.py
# def do_batch_fingerprints(cfg):
# def do_L1_batch(main_ui, cf_level):
# def do_L2_batch(main_ui, cf_level):
# def do_L3_batch(main_ui, cf_level):
# def do_ecostress_batch(main_ui, cf_level):
# def do_fluxnet_batch(main_ui, cf_level):
# def do_reddyproc_batch(main_ui, cf_level):
# def do_concatenate_batch(main_ui, cf_level):
# def do_climatology_batch(main_ui, cf_level):
# def do_cpd_barr_batch(main_ui, cf_level):
# def do_cpd_mchugh_batch(main_ui, cf_level):
# def do_cpd_mcnew_batch(main_ui, cf_level):
# def do_mpt_batch(main_ui, cf_level):
# def do_L4_batch(main_ui, cf_level):
# def do_L5_batch(main_ui, cf_level):
# def do_L6_batch(main_ui, cf_level):
# def do_levels_batch(main_ui):
# 
# Path: scripts/pfp_log.py
# class ConsoleWindowLogHandler(logging.Handler, QObject):
# class CreateLogger(logging.getLoggerClass()):
#     def __init__(self):
#     def emit(self, logRecord):
#     def __init__(self, logger_name, to_log_window=True, to_screen=False, to_file=True, log_file_name="pfp_log"):
# def init_logger(logger_name, log_file_name, to_file=True, to_screen=False):
# def change_logger_filename(logger_name, new_file_name):
# def debug_function_enter(function_name):
# def debug_function_leave(function_name):
# def disable_console_log(logger_name):
# def enable_console_log(logger_name, console_handler):
# def get_batch_log_path(log_path):


import datetime
import logging
import os
import sys
import warnings
from configobj import ConfigObj
from scripts import pfp_batch
from scripts import pfp_log
sys.path.append('scripts')

warnings.filterwarnings("ignore", category=Warning)

logger = logging.getLogger("pfp_log")

class Bunch:
    def __init__(self, **kwds):
        self.__dict__.update(kwds)

if (__name__ == '__main__'):

    # get the logger
    now = datetime.datetime.now()
    log_file_name = "pfp_" + now.strftime("%Y%m%d%H%M") + ".log"
    log_file_name = os.path.join("logfiles", log_file_name)
    logger = pfp_log.CreateLogger("pfp_log", log_file_name=log_file_name,
                                  to_screen=True)

    cfg_file_name = sys.argv[1]
    if not os.path.isfile(cfg_file_name):
        msg = "Batch control file " + cfg_file_name + " not found"
        logger.error(msg)
        sys.exit()

    cfg_batch = ConfigObj(cfg_file_name, indent_type="    ", list_values=False,
                          write_empty_values=True)

    main_ui = Bunch(stop_flag=False, cfg=cfg_batch, mode="batch")


# Path: scripts/pfp_batch.py
# def do_batch_fingerprints(cfg):
# def do_L1_batch(main_ui, cf_level):
# def do_L2_batch(main_ui, cf_level):
# def do_L3_batch(main_ui, cf_level):
# def do_ecostress_batch(main_ui, cf_level):
# def do_fluxnet_batch(main_ui, cf_level):
# def do_reddyproc_batch(main_ui, cf_level):
# def do_concatenate_batch(main_ui, cf_level):
# def do_climatology_batch(main_ui, cf_level):
# def do_cpd_barr_batch(main_ui, cf_level):
# def do_cpd_mchugh_batch(main_ui, cf_level):
# def do_cpd_mcnew_batch(main_ui, cf_level):
# def do_mpt_batch(main_ui, cf_level):
# def do_L4_batch(main_ui, cf_level):
# def do_L5_batch(main_ui, cf_level):
# def do_L6_batch(main_ui, cf_level):
# def do_levels_batch(main_ui):
# 
# Path: scripts/pfp_log.py
# class ConsoleWindowLogHandler(logging.Handler, QObject):
# class CreateLogger(logging.getLoggerClass()):
#     def __init__(self):
#     def emit(self, logRecord):
#     def __init__(self, logger_name, to_log_window=True, to_screen=False, to_file=True, log_file_name="pfp_log"):
# def init_logger(logger_name, log_file_name, to_file=True, to_screen=False):
# def change_logger_filename(logger_name, new_file_name):
# def debug_function_enter(function_name):
# def debug_function_leave(function_name):
# def disable_console_log(logger_name):
# def enable_console_log(logger_name, console_handler):
# def get_batch_log_path(log_path):


# Path: batch.py
import datetime
import logging
import os
import sys
import warnings
from configobj import ConfigObj
from scripts import pfp_batch
from scripts import pfp_log

sys.path.append('scripts')

warnings.filterwarnings("ignore", category=Warning)

logger = logging.getLogger("pfp_log")

class Bunch:
    def __init__(self, **kwds):
        self.__dict__.update(kwds)

if (__name__ == '__main__'):

    # get the logger
    now = datetime.datetime.now()
    log_file_name = "pfp_" + now.strftime("%Y%m%d%H%M") + ".log"
    log_file_name = os.path.join("logfiles", log_file_name)
    logger = pfp_log.CreateLogger("pfp_log", log_file_name=log_file_name,
                                  to_screen=True)

    cfg_file_name = sys.argv[1]
    if not os.path.isfile(cfg_file_name):
        msg = "Batch control file " + cfg_file_name + " not found"
        logger.error(msg)
        sys.exit()

    cfg_batch = ConfigObj(cfg_file_name, indent_type="    ", list_values=False,
                          write_empty_values=True)

    main_ui = Bunch(stop_flag=False, cfg=cfg_batch, mode="batch")


    pfp_batch.do_levels_batch(main_ui)