Raise exception if sdb is not installed
authorDonghoon Shin <dhs.shine@gmail.com>
Thu, 2 Feb 2017 01:44:09 +0000 (10:44 +0900)
committerDonghoon Shin <dhs.shine@gmail.com>
Thu, 2 Feb 2017 01:44:09 +0000 (10:44 +0900)
litmus/cmds/__init__.py
litmus/cmds/cmd_adhoc.py
litmus/cmds/cmd_run.py

index 4852a9617a81ebc4e45097bb58a34630848d0b13..6fa318332a292e94b922852500c045d42b83c9c7 100644 (file)
@@ -14,6 +14,7 @@
 # limitations under the License.
 
 from configparser import RawConfigParser
+from litmus.core.util import call
 
 
 def load_project_list(projects):
@@ -27,3 +28,11 @@ def load_project_list(projects):
         item['name'] = section
         project_list.append(item)
     return project_list
+
+def sdb_does_exist():
+    help_url = 'https://github.com/dhs-shine/litmus#prerequisite'
+    try:
+        call('sdb version', timeout=10)
+    except FileNotFoundError:
+        raise Exception('Please install sdb. Refer to {}'.format(help_url))
+    return
index a1de8e6ad315529fdb16208e26181ea14144c7ce..46dd1c3d59f9d5c03d303d8a296ca9ba166faf48 100755 (executable)
 import os
 import sys
 from litmus.core.util import call
+from litmus.cmd import sdb_does_exist
 
 
 def main(args):
     """docstring for main"""
+    sdb_does_exist()
     project_path = os.path.abspath(args.project_path)
     sys.path.append(project_path)
 
index 6332d6f061b7b03b9951a5e704b7b0dee7a2cd16..fd01765f8379c9470e795f8c5c73f8b09e8128a4 100755 (executable)
 # limitations under the License.
 
 import sys
-from litmus.cmds import load_project_list
+from litmus.cmds import load_project_list, sdb_does_exist
 
 
 def main(args):
     """docstring for main"""
+    sdb_does_exist()
     prj_list = load_project_list(args.projects)
     project = next((prj for prj in prj_list if prj['name'] == args.project),
                    None)