Example #1
0
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
Example #2
0
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())