[nostalgia/scripts/pybb] Make gracefully exit upon Ctl-C

This commit is contained in:
Gary Talent 2021-02-21 00:30:14 -06:00
parent 20ede1b2d7
commit c82b72d8aa

View File

@ -5,10 +5,10 @@
import os import os
import shutil import shutil
import stat
import subprocess import subprocess
import sys import sys
def mkdir(path): def mkdir(path):
if not os.path.exists(path) and os.path.isdir(path): if not os.path.exists(path) and os.path.isdir(path):
os.mkdir(path) os.mkdir(path)
@ -29,7 +29,7 @@ def cmake_build(base_path, target):
if err != 0: if err != 0:
sys.exit(err) sys.exit(err)
if __name__ == '__main__': def main():
if sys.argv[1] == 'mkdir': if sys.argv[1] == 'mkdir':
mkdir(sys.argv[2]) mkdir(sys.argv[2])
elif sys.argv[1] == 'rm': elif sys.argv[1] == 'rm':
@ -37,3 +37,10 @@ if __name__ == '__main__':
rm(sys.argv[i]) rm(sys.argv[i])
elif sys.argv[1] == 'cmake-build': elif sys.argv[1] == 'cmake-build':
cmake_build(sys.argv[2], sys.argv[3] if len(sys.argv) > 3 else None) cmake_build(sys.argv[2], sys.argv[3] if len(sys.argv) > 3 else None)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
sys.exit(1)