diff options
-rwxr-xr-x | linhes/linhes-system/PKGBUILD | 4 | ||||
-rwxr-xr-x | linhes/linhes-system/balance_storage_groups.py | 44 |
2 files changed, 30 insertions, 18 deletions
diff --git a/linhes/linhes-system/PKGBUILD b/linhes/linhes-system/PKGBUILD index c67f521..942975d 100755 --- a/linhes/linhes-system/PKGBUILD +++ b/linhes/linhes-system/PKGBUILD @@ -1,6 +1,6 @@ pkgname=linhes-system pkgver=9.0.0 -pkgrel=74 +pkgrel=76 arch=('x86_64') #install=$pkgname.install pkgdesc="Everything that makes LinHES a system" @@ -27,7 +27,7 @@ source=($binfiles 'system-sudo.rules' 'linhes-profile.sh' 'lh_sqlserver.cnf' 'lh_restart_needed.hook' 'lh_system_start.sh.desktop' 'rc6_mce.toml' 'recordings.cron' 'rsyslog.mythtv.conf') sha256sums=('e6eaa2fb4819fa60cb05b4d2e7328d2914af3a73028a735ec4d56e7ece33ecc0' - '1ec3c266cafb0c1b231e88df88b97fec1a1b7465b5d95a0c1e64c8cb727b7c47' + '1115809a2d80c1ead7cfc5df05e1d6427255912a8303594574b3be23d3d3e4f1' '97fe9e851c782fa9f85c5b69b110ccff2817dd4fa2a6d9ff6ee225dc558677e4' 'ff261f41efec8a9963f9f59100cbe75f015028a2ed3a863ce0cb473f2ebb7b76' '8b54c31b8efde3917f603c5307bebb0a2a00239ad9a983c2f5d8120003256449' diff --git a/linhes/linhes-system/balance_storage_groups.py b/linhes/linhes-system/balance_storage_groups.py index e525a27..d91da60 100755 --- a/linhes/linhes-system/balance_storage_groups.py +++ b/linhes/linhes-system/balance_storage_groups.py @@ -1,7 +1,8 @@ #!/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 +movingFiles = False def getFreeSpaceForDir(dir): stats = os.statvfs(dir) @@ -24,9 +25,12 @@ def sizeof_fmt(num, suffix='B'): return "%.1f %s%s" % (num, 'Yi', suffix) def signal_handler(signal, frame): - print("\nWill quit when file has been moved.\nMoving File...") - global shouldQuit - shouldQuit = True + if movingFiles: + print("\nWill quit when file has been moved.\nMoving File...") + global shouldQuit + shouldQuit = True + else: + sys.exit(0) if __name__ == '__main__': parser = argparse.ArgumentParser() @@ -116,26 +120,33 @@ if __name__ == '__main__': print(filePathToMove + " is too big to move to " + leastFull[0]) sys.exit() - print("------------------------------------------------") - print("Move File:") - print(" " + filePathToMove) - print(" Size: " + sizeof_fmt(os.path.getsize(filePathToMove))) - print("To:") - print(" " + leastFull[0]) - print(" Available: " + sizeof_fmt(getFreeSpaceForDir(leastFull[0]))) - # Move file if cmdargs.checkonly: print("------------------------------------------------") print("Check Only option was used. No files were moved.") shouldQuit = True else: + 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("------------------------------------------------") - 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() + print("Move File:") + print(" " + filePathToMove) + print(" Size: " + sizeof_fmt(os.path.getsize(filePathToMove))) + print("To:") + print(" " + leastFull[0]) + print(" Available: " + sizeof_fmt(getFreeSpaceForDir(leastFull[0]))) print("Moving File...") + movingFiles = True try: shutil.move(filePathToMove, leastFull[0]) # eg. src and dest are the same file @@ -151,3 +162,4 @@ if __name__ == '__main__': for p in pngFiles: os.remove(p) print(" " + p) + movingFiles = False |