-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
25 lines (21 loc) · 1.07 KB
/
main.py
File metadata and controls
25 lines (21 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import argparse
import config
import clean_file
import logging
import telegram_message
def main():
parser = argparse.ArgumentParser(description="Process clean file especially logs or old wal file")
parser.add_argument("--d", type=str, help="base directory", required=False)
parser.add_argument("--a", type=int, help="duration in day", required=False)
arg = parser.parse_args()
logging.debug(f"Reading config file from :{config.CONFIG.config_path}")
base_directory = arg.d if arg.d else config.CONFIG.base_path
duration = arg.a if arg.a else config.CONFIG.age
logging.debug(f"base dir : {base_directory} , duration older than : {duration} days")
total_file, total_file_size = clean_file.clean_file(base_directory, duration)
logging.debug(f"Done clean file :")
size_in_format = clean_file.format_file_size(total_file_size)
logging.debug(f"Total file : {total_file} , size : {size_in_format}")
telegram_message.send_message(f" clean file at {base_directory} #: {total_file}, size: {size_in_format}")
if __name__ == "__main__":
main()