summaryrefslogtreecommitdiff
path: root/litmus/cmds/cmd_rm.py
diff options
context:
space:
mode:
Diffstat (limited to 'litmus/cmds/cmd_rm.py')
-rwxr-xr-xlitmus/cmds/cmd_rm.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/litmus/cmds/cmd_rm.py b/litmus/cmds/cmd_rm.py
new file mode 100755
index 0000000..1321f9d
--- /dev/null
+++ b/litmus/cmds/cmd_rm.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python3
+# Copyright 2015-2016 Samsung Electronics Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import shutil
+import logging
+from configparser import RawConfigParser
+
+
+def main(args):
+ """docstring for main"""
+ configparser = RawConfigParser()
+ configparser.read(args.projects)
+
+ if args.project in configparser.sections():
+ path = configparser.get(args.project, 'path')
+ shutil.rmtree(path)
+
+ configparser.remove_section(args.project)
+ with open(args.projects, 'w') as f:
+ configparser.write(f)
+ logging.debug('Project {0} is removed'.format(args.project))
+ else:
+ raise Exception('Project {0} does not exists'.format(args.project))