diff --git a/compress_logger/cleanup.bash b/compress_logger/cleanup.bash new file mode 100644 index 0000000..bf870b9 --- /dev/null +++ b/compress_logger/cleanup.bash @@ -0,0 +1,12 @@ +rm -f ~/sea/log/auto* +rm -f ~/sea/log/log-201* +rm -f ~/sea/log/log-2020 +rm -f ~/sea/log/log-2021 +rm -f ~/sea/log/log-2022 +rm -f ~/sea/log/log-2023 +rm -f ~/sea/log/log-2024 +rm -rf ~/sea/history/* +rm -f ~/sea/*_sea_logger.tar +python3 ~/sea/compress_logger/compress.py -x +python3 ~/sea/compress_logger/lz4.py 2021 +mv ~/sea/gzlogger ~/sea_logger_trash_/ diff --git a/compress_logger/compress.py b/compress_logger/compress.py index 4a880e4..5f7a948 100644 --- a/compress_logger/compress.py +++ b/compress_logger/compress.py @@ -87,6 +87,13 @@ def treat(action, instrument='', years='past', vars=None): yrs.remove(time.strftime("%Y")) except ValueError: pass + elif years == 'auto': + os.chdir(gzbase) + yrs = [] + for year in glob('20*'): + if not os.path.exists(f'../logger/{year}.tar.lz4'): + yrs.append(year) + os.chdir(logbase) else: yrs = years for year in yrs: @@ -95,7 +102,11 @@ def treat(action, instrument='', years='past', vars=None): if action == COMPRESS: os.chdir(logdir) else: - os.chdir(gzdir) + try: + os.chdir(gzdir) + except Exception as e: + print(e) + continue if not vars: varlist = list(glob('*')) else: @@ -145,8 +156,8 @@ if __name__ == '__main__': else: addto.append(opt) if len(years) == 0: - years = 'past' - if years not in ('past', 'all'): + years = 'auto' + if years not in ('past', 'all', 'auto'): for year in years: assert(2007 <= int(year) <= 2030) if len(instruments) == 0: