Esempio n. 1
0
def run_monthly(last: bool = False, dry_run: bool = False):
    """
    special monthly procedure
    """
    if dry_run:
        logger.log("robot", "Dry run procedure for testing monthly procedures")
    else:
        logger.log("exec", "run monthly procedures")
    from p05_month import run
    e = run(dry_run)
    for k, v in e.items():
        if v != "Ok":
            logger.log_error("robot", k + " -> " + v)
    #
    # pack monthly
    #
    cwd = os.getcwd()
    os.chdir(log_dir)
    month_log = full_logfile.parent / (full_logfile.stem + "_month_" + str(the_date.year) + "_" + str(the_date.month) + ".tgz")
    if month_log.exists():
        return  # already done
    year_log = full_logfile.parent / (full_logfile.stem + "_year_" + str(the_date.year) + ".tgz")
    if year_log.exists():
        return  # already done
    cmd = "tar czf " + str(month_log) + " " + str(full_logfile)
    if dry_run:
        logger.log("monthly", "Packing dry")
        logger.log("monthly", ">>> " + cmd)
    else:
        logger.log("monthly", "Packing")
        system_exec(cmd)
        if not last:
            logger.new_log()
    os.chdir(cwd)
Esempio n. 2
0
def run_yearly(dry_run: bool = False):
    """
    special yearly procedures
    """
    run_monthly(True, dry_run)
    if dry_run:
        logger.log("robot", "Dry run procedure for testing yearly procedures")
    else:
        logger.log("exec", "run yearly procedures")
    from p06_year import run
    e = run(dry_run)
    for k, v in e.items():
        if v != "Ok":
            logger.log_error("robot", k + " -> " + v)
    #
    # pack yearly
    #
    cwd = os.getcwd()
    os.chdir(log_dir)
    year_log = full_logfile.parent / (full_logfile.stem + "_year_" + str(the_date.year) + ".tgz")
    if year_log.exists():
        return  # already done
    cmd = "tar czf " + str(year_log) + " " + \
          str(full_logfile.parent / full_logfile.stem) + "_month_" + str(the_date.year) + "_*.tgz "
    if dry_run:
        logger.log("yearly", "Packing dry:")
        logger.log("yearly", ">>> " + cmd)
        logger.log("yearly", ">>> logger.new_log")
    else:
        logger.log("yearly", "Packing")
        system_exec(cmd)
        logger.new_log()
    os.chdir(cwd)
    logger.log("yearly", "Happy new year!")
Esempio n. 3
0
def run_30sec(dry_run: bool = False):
    """
    procedure run every 30 seconds
    """
    if dry_run:
        logger.log("robot", "Dry run procedure for testing 30 seconds procedures")
    from p00_30seconds import run
    e = run(dry_run)
    for k, v in e.items():
        if v != "Ok":
            logger.log_error("robot", k + " -> " + v)
Esempio n. 4
0
def run_10min(dry_run: bool = False):
    """
    procedure run every 10 minutes
    """
    if dry_run:
        logger.log("robot", "Dry run procedure for testing 10 minutes procedures")
    else:
        logger.log("exec", "run 10 minutes procedures")
    from p01_tenmin import run
    e = run(dry_run)
    for k, v in e.items():
        if v != "Ok":
            logger.log_error("robot", k + " -> " + v)
Esempio n. 5
0
def run_special(dry_run: bool = False):
    """
    run the content of the special folder
    """
    if dry_run:
        logger.log("robot", "Dry run procedure for testing special procedures")
    else:
        logger.log("exec", "run special procedures")
    from p07_special import run
    e = run(dry_run)
    for k, v in e.items():
        if v != "Ok":
            logger.log_error("robot", k + " -> " + v)
Esempio n. 6
0
def run_weekly(dry_run: bool = False):
    """
    weekly procedure
    """
    run_daily(dry_run)
    if dry_run:
        logger.log("robot", "Dry run procedure for testing weekly procedures")
    else:
        logger.log("exec", "run weekly procedures")
    from p04_week import run
    e = run(dry_run)
    for k, v in e.items():
        if v != "Ok":
            logger.log_error("robot", k + " -> " + v)
Esempio n. 7
0
def run_daily(dry_run: bool = False):
    """
    daily procedure
    """
    run_hourly(dry_run, True)
    if dry_run:
        logger.log("robot", "Dry run procedure for testing daily procedures")
    else:
        logger.log("exec", "run daily procedures")
    from p03_day import run
    e = run(dry_run)
    for k, v in e.items():
        if v != "Ok":
            logger.log_error("robot", k + " -> " + v)
Esempio n. 8
0
def run_hourly(dry_run: bool = False, from_daily: bool = False):
    """
    hourly procedures
    """
    run_10min(dry_run)
    if dry_run:
        logger.log("robot", "Dry run procedure for testing hourly procedures")
    else:
        logger.log("exec", "run hourly procedures")
    from p02_hour import run
    e = run(dry_run)
    for k, v in e.items():
        if v != "Ok":
            logger.log_error("robot", k + " -> " + v)