def get_dir_path(sibling): """Get a path to the directory of this script. By default, the canonical path (symlinks resolved) will be returned. In some environments the canonical directory is not sufficient because different parts of the SDK are referenced by symlinks, including this very module's file. In this case, the non-canonical path to this file's directory will be returned (i.e., the directory where the symlink lives, not the directory where it points). Args: sibling: Relative path to a sibling of this module file. Choose a sibling that is potentially symlinked into the parent directory. Returns: A directory name. Raises: ValueError: If no proper path could be determined. """ return wrapper_util.get_dir_path(__file__, sibling)
def get_dir_path(sibling): """Get a path to the directory of this script. By default, the canonical path (symlinks resolved) will be returned. In some environments the canonical directory is not sufficient because different parts of the SDK are referenced by symlinks, including this very module's file. In this case, the non-canonical path to this file's directory will be returned (i.e., the directory where the symlink lives, not the directory where it points). Args: sibling: Relative path to a sibling of this module file. Choose a sibling that is potentially symlinked into the parent directory. Returns: A directory name. Raises: ValueError: If no proper path could be determined. """ return wrapper_util.get_dir_path(__file__, sibling)
sys_path = sys.path try: sys.path = [os.path.dirname(__file__)] + sys.path import wrapper_util finally: sys.path = sys_path wrapper_util.reject_old_python_versions((2, 7)) _DIR_PATH = wrapper_util.get_dir_path(__file__, os.path.join('lib', 'ipaddr')) _PATHS = wrapper_util.Paths(_DIR_PATH) EXTRA_PATHS = _PATHS.v2_extra_paths def fix_sys_path(extra_extra_paths=()): """Fix the sys.path to include our extra paths. fix_sys_path should be called before running testbed-based unit tests so that third-party modules are correctly added to sys.path. """
import os import sys sys_path = sys.path try: sys.path = [os.path.dirname(__file__)] + sys.path import wrapper_util finally: sys.path = sys_path wrapper_util.reject_old_python_versions((2, 7)) _DIR_PATH = wrapper_util.get_dir_path(__file__, os.path.join('lib', 'ipaddr')) _PATHS = wrapper_util.Paths(_DIR_PATH) EXTRA_PATHS = _PATHS.v2_extra_paths def fix_sys_path(extra_extra_paths=()): """Fix the sys.path to include our extra paths. fix_sys_path should be called before running testbed-based unit tests so that third-party modules are correctly added to sys.path. """ sys.path[1:1] = EXTRA_PATHS def _run_file(file_path, globals_):
#!/usr/bin/env python import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gaemeta.settings") PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) import wrapper_util dir_path = wrapper_util.get_dir_path('wrapper_util.py', os.path.join('lib', 'ipaddr')) paths = wrapper_util.Paths(dir_path) sys.path[1:1] = paths.script_paths('dev_appserver.py') import yaml conf = yaml.load(open('app.yaml')) app_id = "dev~{}".format(conf['application']) os.environ.setdefault("APPLICATION_ID", app_id) from google.appengine.tools.devappserver2 import api_server api_server.test_setup_stubs(app_id=app_id, application_root=PROJECT_DIR, datastore_path='/var/db/gaedata/datastore.db') from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)