diff options
Diffstat (limited to 'linhes/linhes-system/empty_storage_groups.py')
| -rwxr-xr-x | linhes/linhes-system/empty_storage_groups.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/linhes/linhes-system/empty_storage_groups.py b/linhes/linhes-system/empty_storage_groups.py index c181242..c36437e 100755 --- a/linhes/linhes-system/empty_storage_groups.py +++ b/linhes/linhes-system/empty_storage_groups.py @@ -1,6 +1,6 @@ #!/usr/bin/python -import argparse, glob, operator, os, random, shutil, subprocess, sys, signal +import argparse, glob, operator, os, random, shutil, subprocess, sys, signal, time shouldQuit = False def getFreeSpaceForDir(dir): @@ -24,6 +24,8 @@ def sizeof_fmt(num, suffix='B'): return "%.1f %s%s" % (num, 'Yi', suffix) def signal_handler(signal, frame): + if isBusy: + sys.exit(0) print("\nWill quit when file has been moved.\nMoving File...") global shouldQuit shouldQuit = True @@ -163,11 +165,19 @@ if __name__ == '__main__': print("Check Only option was used. No files were moved.") shouldQuit = True else: - print("------------------------------------------------") - print("Checking System Status...") - if subprocess.call(["/usr/bin/python", "/usr/bin/idle.py", "-s"]): - print(" System is busy. The file will not be moved.") - sys.exit() + global isBusy + isBusy = True + while isBusy: + if shouldQuit: + sys.exit(0) + print("------------------------------------------------") + print("Checking System Status...") + if subprocess.call(["/usr/bin/python", "/usr/bin/idle.py", "-s"]): + print(" System is busy. The file will not be moved.") + print(" Waiting 5 minutes before trying again.") + time.sleep(300) + else: + isBusy = False print("Moving File...") try: shutil.move(filePathToMove, leastFull[0]) |
