From: Konrad Hinsen Date: Sat, 29 Dec 2012 19:41:13 +0000 (-0500) Subject: swc-installation-test.py: Add installation-testing script X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d8fb9e3e8772b63b37c69eb2901c616d2acfa765;p=swc-boot-camp.git swc-installation-test.py: Add installation-testing script The content of this script was posted by Greg Wilson and attributed to Konrad Hinsen [1]. [1]: https://github.com/swcarpentry/website/issues/38#issuecomment-11189525 --- d8fb9e3e8772b63b37c69eb2901c616d2acfa765 diff --git a/swc-installation-test.py b/swc-installation-test.py new file mode 100644 index 0000000..4c76274 --- /dev/null +++ b/swc-installation-test.py @@ -0,0 +1,60 @@ +# Run this as +# +# python swc_installation_test.py +# +# If if says nothing, everything is fine! + +import os + +python_modules = ['nose'] + +tools = ['bash', + ('easy_install', 'Python setuptools'), + ('hg', 'Mercurial'), + 'make', + ('nosetests', 'Python nose'), + 'sqlite3'] + +# Check Python modules/packages + +def check_python_modules(module_names): + for module_name in module_names: + try: + __import__(module_name) + except ImportError: + print "Python module '%s' is missing" % module_name + + +# Check command line tools + +def check_command_line_tools(tools): + shell_path = os.environ['PATH'].split(':') + for tool in tools: + if isinstance(tool, basestring): + command = tool + package = None + else: + command, package = tool + found = False + for directory in shell_path: + filename = os.path.join(directory, command) + if os.access(filename, os.X_OK) and not os.path.isdir(filename): + found = True + break + if not found: + if package is None: + print "Command line tool '%s' is missing" % command + else: + print "Command line tool '%s' " \ + "from package '%s' is missing" % (command, package) + + +# Run all the checks + +def main(): + check_python_modules(python_modules) + check_command_line_tools(tools) + + +if __name__ == '__main__': + main()