def django_execute_from_command_line(argv=None): """ A simple method that runs a ManagementUtility. """ from os.path import realpath script_file_name=realpath((argv or sys.argv)[0]) try: project_directory = find_basedir(os.getcwd())[1] except: #TODO exlude project based commands from os.path import dirname project_directory = dirname(dirname(script_file_name)) from thepian.conf import structure, use_structure, use_default_structure structure.SCRIPT_PATH = script_file_name try: from os.path import join sys.path.insert(0,join(project_directory,"conf")) #TODO too simplistic, use real project tree import structure as conf_structure use_structure(conf_structure) site.addsitedir(structure.PYTHON_DIR) except ImportError: use_default_structure() structure.COMMAND_VARIABLE_PREFIX = "MAESTRO" settings_module = determine_settings_module(argv or sys.argv) from thepian.conf import use_settings, settings use_settings(settings_module) import django.conf django.conf.settings.configure(**settings.__dict__) import django.core.management django.core.management.execute_from_command_line(argv)
def main(): from os.path import join, dirname abs__file__() sys.path = sys.path[:-3] # remove pypy libs #TODO base it on the common dir of executable and library sys.path.append(join(dirname(dirname(sys.executable)),"src","tornado")) sys.path.append(join(dirname(dirname(sys.executable)),"src","thepian-lib")) sys.path.append(join(dirname(dirname(sys.executable)),"src","redis-py")) sys.path.append(join(dirname(dirname(sys.executable)),"src","brukva")) sys.path.append(join(dirname(dirname(sys.executable)),"Library","PyMeta2")) # paths_in_sys = addsitepackages(paths_in_sys) setquit() setcopyright() sethelper() aliasmbcs() setencoding() execsitecustomize() # Remove sys.setdefaultencoding() so that users cannot change the # encoding after initialization. The test for presence is needed when # this module is run as a script, because this code is executed twice. if hasattr(sys, "setdefaultencoding"): del sys.setdefaultencoding try: from thepian.conf import use_settings, structure, use_cwd_structure use_cwd_structure() use_settings(structure.determine_settings_module()) except Exception, e: print 'structure conf failed:: ',e
def test_use_settings(): from thepian.conf import settings, use_settings from samples import sample_settings use_settings(sample_settings) assert settings.ROOT_URLCONF == sample_settings.ROOT_URLCONF assert settings.__file__ == sample_settings.__file__ assert settings.INTERNAL_IPS == (sample_settings.INTERNAL_IPS,)
def execute_from_command_line(argv=None): """ A simple method that runs a ManagementUtility. obsolete """ import os, sys from os.path import realpath script_file_name=realpath((argv or sys.argv)[0] or sys.executable) try: project_directory = find_basedir(os.getcwd())[1] except Exception,e: print e, ':: will use Thepian Maestro as project' #TODO rather than fail if used outside a project, use thepian.config as project? #TODO exlude project based commands from os.path import dirname project_directory = dirname(dirname(script_file_name)) from thepian.conf import structure, use_structure, use_default_structure structure.SCRIPT_PATH = script_file_name try: import structure as conf_structure use_structure(conf_structure) #obsolete site.addsitedir(structure.PYTHON_DIR) except ImportError: use_default_structure() from thepian.conf import use_settings use_settings(structure.determine_settings_module())
from thepian.conf import structure, use_structure, use_default_structure structure.SCRIPT_PATH = script_file_name try: from os.path import join sys.path.insert(0,join(project_directory,"conf")) #TODO too simplistic, use real project tree import structure as conf_structure use_structure(conf_structure) site.addsitedir(structure.PYTHON_DIR) except ImportError: use_default_structure() structure.COMMAND_VARIABLE_PREFIX = "MAESTRO" from thepian.conf import use_settings, settings use_settings(determine_settings_module(argv or sys.argv)) import django.conf django.conf.settings.configure(**settings.__dict__) COMMANDS.execute(argv) def django_execute_from_command_line(argv=None): """ A simple method that runs a ManagementUtility. """ from os.path import realpath script_file_name=realpath((argv or sys.argv)[0]) try: project_directory = find_basedir(os.getcwd())[1] except: #TODO exlude project based commands