Teach all non-daemon scripts how to cleanly exit on CTRL-c

Using: raise SystemExit('some message')

is equivalent to:
sys.stderr.write('some message\n')
sys.exit(1)
This commit is contained in:
Jeff Schroeder 2011-12-20 19:09:27 -08:00
parent 1b8ec74efd
commit 021cebbbf3
5 changed files with 20 additions and 5 deletions

View file

@ -14,4 +14,7 @@ def main():
client.run()
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
raise SystemExit('\nExiting gracefully on Ctrl-c')

View file

@ -15,4 +15,7 @@ def main():
client.run()
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
raise SystemExit('\nExiting gracefully on Ctrl-c')

View file

@ -14,4 +14,7 @@ def main():
cp_.run()
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
raise SystemExit('\nExiting gracefully on Ctrl-c')

View file

@ -14,4 +14,7 @@ def main():
saltkey.run()
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
raise SystemExit('\nExiting gracefully on Ctrl-c')

View file

@ -14,4 +14,7 @@ def main():
client.run()
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
raise SystemExit('\nExiting gracefully on Ctrl-c')