From eea6240fc6ae11b3692dc09a116a8ad7c2e3f269 Mon Sep 17 00:00:00 2001 From: Donghoon Shin Date: Thu, 22 Sep 2016 08:49:03 +0900 Subject: [PATCH] Update cmd_rm.py : Ask user to confirm and add more exception handler Change-Id: I5fcab6d7547ff370525d3fd8404f2dffb838d3a8 --- CHANGES.txt | 4 ++++ README.md | 2 +- debian/changelog | 6 ++++++ litmus/__init__.py | 2 +- litmus/cmds/cmd_rm.py | 11 ++++++++++- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 7b1efa5..d5af636 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -31,3 +31,7 @@ Version 0.3.0 21 Sep 2016 - Add projects/topology param at command prompt - Support multiple mock devices in topology - Add global lock for mock device type + +Version 0.3.1 22 Sep 2016 +--------------------------- +- Update cmd_rm handler diff --git a/README.md b/README.md index 1abbb1a..614c979 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Buliding & installing $ mv litmus litmus-0.3.0 - $ tar cvfz litmus-0.3.0.orig.tar.gz litmus-0.3.0 + $ tar cvfz litmus_0.3.0.orig.tar.gz litmus-0.3.0 1. Build a deb package with debuild diff --git a/debian/changelog b/debian/changelog index 1cdce25..6c83b99 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +litmus (0.3.1-1) unstable; urgency=low + + * Update cmd_rm handler + + -- Donghoon Shin Thu, 22 Sep 2016 07:42:00 +0900 + litmus (0.3.0-1) unstable; urgency=low * Update projects/topology file location diff --git a/litmus/__init__.py b/litmus/__init__.py index 724e475..3cb3ccd 100644 --- a/litmus/__init__.py +++ b/litmus/__init__.py @@ -14,7 +14,7 @@ # limitations under the License. import os -__version__ = '0.3.0' +__version__ = '0.3.1' _homedir_ = os.path.expanduser('~') _confdir_ = os.path.join(_homedir_, '.litmus') _duts_ = os.path.join(_confdir_, 'topology') 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