From cb0547411aa372d00e86afacdf30290e1e4891a9 Mon Sep 17 00:00:00 2001 From: Donghoon Shin Date: Thu, 22 Sep 2016 07:31:39 +0900 Subject: [PATCH] Update cmd_rm.py : Ask user to confirm and add more exception handler --- litmus/cmds/cmd_rm.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/litmus/cmds/cmd_rm.py b/litmus/cmds/cmd_rm.py index 1321f9d..ca0d636 100755 --- a/litmus/cmds/cmd_rm.py +++ b/litmus/cmds/cmd_rm.py @@ -24,8 +24,17 @@ def main(args): configparser.read(args.projects) if args.project in configparser.sections(): + + yn = input('Do you really want to remove {0}? (y/N) ' + .format(args.project)) + if not yn or yn.capitalize().startswith('N'): + return + path = configparser.get(args.project, 'path') - shutil.rmtree(path) + try: + shutil.rmtree(path) + except FileNotFoundError: + logging.debug('{0} does not exists'.format(path)) configparser.remove_section(args.project) with open(args.projects, 'w') as f: -- 2.34.1