mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 01:30:20 +00:00
Nicer handling of user keyboard interruption
This commit is contained in:
parent
0add87e7b9
commit
6294c67b12
1 changed files with 13 additions and 7 deletions
|
@ -78,6 +78,7 @@ def mod_data(opts, full):
|
|||
|
||||
def scan(opts):
|
||||
'''
|
||||
Scan the provided root for python source files
|
||||
'''
|
||||
ret = {}
|
||||
for root, dirs, files in os.walk(opts['root']):
|
||||
|
@ -92,6 +93,7 @@ if __name__ == '__main__':
|
|||
if not HAS_ARGPARSE:
|
||||
print('The argparse python module is required')
|
||||
opts = parse()
|
||||
try:
|
||||
scand = scan(opts)
|
||||
if opts['format'] == 'yaml':
|
||||
print(yaml.dump(scand))
|
||||
|
@ -99,3 +101,7 @@ if __name__ == '__main__':
|
|||
print(json.dumps(scand))
|
||||
else:
|
||||
pprint.pprint(scand)
|
||||
exit(0)
|
||||
except KeyboardInterrupt:
|
||||
print('\nInterrupted on user request', file=sys.stderr)
|
||||
exit(1)
|
||||
|
|
Loading…
Add table
Reference in a new issue