diff --git a/deploy/__init__.py b/deploy/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/deploy/paths.py b/deploy/paths.py new file mode 100644 index 00000000..9b9cfe29 --- /dev/null +++ b/deploy/paths.py @@ -0,0 +1,39 @@ +# Case Conductor is a Test Case Management system. +# Copyright (C) 2011 uTest Inc. +# +# This file is part of Case Conductor. +# +# Case Conductor is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Case Conductor is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Case Conductor. If not, see . + +import os, sys, site + + +def add_vendor_lib(): + base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + vendor_lib = os.path.join( + base_dir, "requirements", "vendor", "lib", "python") + + orig_sys_path = set(sys.path) + + # Add project base directory and vendor-lib to sys.path (using + # site.addsitedir for the latter so pth files are processed) + site.addsitedir(vendor_lib) + + # Give new entries precedence over global Python environment + new_sys_path = [] + for item in list(sys.path): + if item not in orig_sys_path: + new_sys_path.append(item) + sys.path.remove(item) + sys.path[:0] = new_sys_path diff --git a/deploy/vendor.wsgi b/deploy/vendor.wsgi index 3bc91a8b..765574fe 100644 --- a/deploy/vendor.wsgi +++ b/deploy/vendor.wsgi @@ -1,26 +1,11 @@ # A WSGI entry-point that uses requirements/vendor for dependencies. - -import os, sys, site +import os, sys base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -vendor_lib = os.path.join(base_dir, "requirements", "vendor", "lib", "python") - - -orig_sys_path = set(sys.path) - -# Add project base directory and vendor-lib to sys.path (using site.addsitedir -# for the latter so pth files are processed) -sys.path.append(base_dir) -site.addsitedir(vendor_lib) - -# Give new entries precedence over global Python environment -new_sys_path = [] -for item in list(sys.path): - if item not in orig_sys_path: - new_sys_path.append(item) - sys.path.remove(item) -sys.path[:0] = new_sys_path +sys.path.insert(0, base_dir) +from deploy.paths import add_vendor_lib +add_vendor_lib() # Set default settings and instantiate application diff --git a/manage-vendor.py b/manage-vendor.py new file mode 100755 index 00000000..36710149 --- /dev/null +++ b/manage-vendor.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +# Case Conductor is a Test Case Management system. +# Copyright (C) 2011 uTest Inc. +# +# This file is part of Case Conductor. +# +# Case Conductor is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Case Conductor is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Case Conductor. If not, see . + +""" +Runs a Django management command, using the vendor library. + +""" +import os, sys +from deploy.paths import add_vendor_lib + +if __name__ == "__main__": + add_vendor_lib() + + os.environ["DJANGO_SETTINGS_MODULE"] = "ccui.settings.default" + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv)