lz4.py: move trash and write out a message how to delete the trash
This commit is contained in:
@@ -20,7 +20,8 @@ def treat(instrument, yearlimit):
|
|||||||
logbase = '%slogger/' % instdir(instrument)
|
logbase = '%slogger/' % instdir(instrument)
|
||||||
os.chdir(logbase)
|
os.chdir(logbase)
|
||||||
print('chdir', logbase)
|
print('chdir', logbase)
|
||||||
os.makedirs('trash', exist_ok=True)
|
trash = '../loggertrash'
|
||||||
|
os.makedirs(trash, exist_ok=True)
|
||||||
for ynum in range(2007, 2040):
|
for ynum in range(2007, 2040):
|
||||||
year = str(ynum)
|
year = str(ynum)
|
||||||
cyear = f'{year}.tar.lz4'
|
cyear = f'{year}.tar.lz4'
|
||||||
@@ -31,9 +32,9 @@ def treat(instrument, yearlimit):
|
|||||||
else:
|
else:
|
||||||
os.system(f'tar cf - {year} | lz4 - {cyear}')
|
os.system(f'tar cf - {year} | lz4 - {cyear}')
|
||||||
print(cyear, 'created')
|
print(cyear, 'created')
|
||||||
if os.path.exists(f'trash/{year}'):
|
if os.path.exists(f'{trash}/{year}'):
|
||||||
shutil.rmtree(f'trash/{year}')
|
shutil.rmtree(f'{trash}/{year}')
|
||||||
os.rename(year, f'trash/{year}')
|
os.rename(year, f'{trash}/{year}')
|
||||||
else:
|
else:
|
||||||
print('no', year)
|
print('no', year)
|
||||||
else:
|
else:
|
||||||
@@ -43,7 +44,7 @@ def treat(instrument, yearlimit):
|
|||||||
else:
|
else:
|
||||||
os.system(f'lz4 -d {cyear} | tar xf -')
|
os.system(f'lz4 -d {cyear} | tar xf -')
|
||||||
print(year, 'created')
|
print(year, 'created')
|
||||||
os.rename(cyear, f'trash/{cyear}')
|
os.rename(cyear, f'{trash}/{cyear}')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@@ -102,3 +103,8 @@ if __name__ == '__main__':
|
|||||||
time.sleep(min(1.0, now - t1)) # be nice
|
time.sleep(min(1.0, now - t1)) # be nice
|
||||||
t1 = now
|
t1 = now
|
||||||
treat(instrument, year)
|
treat(instrument, year)
|
||||||
|
print('if you are sure nothing is lost, you may delete loggertrash:')
|
||||||
|
for instrument in instruments:
|
||||||
|
tr = instdir(instrument) + 'loggertrash'
|
||||||
|
print(f' rm -r {tr}')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user