def runserver_passthru_argv(): """ Execute dev_appserver with appropriate parameters. For more details, please invoke 'python manage.py runserver --help'. """ from google.appengine.tools import dev_appserver_main progname = "manage.py runserver" args = [] args.extend(sys.argv[2:]) p = get_datastore_paths() if not args_have_option(args, "--datastore_path"): args.extend(["--datastore_path", p[0]]) if not args_have_option(args, "--default_partition"): args.extend(['--default_partition', '']) if not args_have_option(args, "--history_path"): args.extend(["--history_path", p[1]]) # Append the current working directory to the arguments. if "-h" in args or "--help" in args: render_dict = dev_appserver_main.DEFAULT_ARGS.copy() render_dict['script'] = "manage.py runserver" print_status(dev_appserver_main.__doc__ % render_dict) sys.stdout.flush() sys.exit(0) dev_appserver_main.main([progname] + args + [os.getcwdu()])
def shell(datastore_path='', history_path='', useful_imports=True, use_ipython=True, use_sqlite=False): """ Start a new interactive python session.""" banner = 'Interactive Kay Shell' if useful_imports: namespace = create_useful_locals() else: namespace = {} appid = get_appid() os.environ['APPLICATION_ID'] = appid p = get_datastore_paths() if not datastore_path: datastore_path = p[0] if not history_path: history_path = p[1] apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap() if use_sqlite: from google.appengine.datastore import datastore_sqlite_stub stub = datastore_sqlite_stub.DatastoreSqliteStub( appid, datastore_path, history_path) else: stub = datastore_file_stub.DatastoreFileStub(appid, datastore_path, history_path) apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', stub) if use_ipython: try: import IPython except ImportError: pass else: sh = IPython.Shell.IPShellEmbed(argv='', banner=banner) sh(global_ns={}, local_ns=namespace) return sys.ps1 = '%s> ' % appid if readline is not None: readline.parse_and_bind('tab: complete') atexit.register(lambda: readline.write_history_file(HISTORY_PATH)) if os.path.exists(HISTORY_PATH): readline.read_history_file(HISTORY_PATH) from code import interact interact(banner, local=namespace)
def shell(datastore_path='', history_path='', useful_imports=True, use_ipython=True, use_sqlite=False): """ Start a new interactive python session.""" banner = 'Interactive Kay Shell' if useful_imports: namespace = create_useful_locals() else: namespace = {} appid = get_appid() os.environ['APPLICATION_ID'] = appid p = get_datastore_paths() if not datastore_path: datastore_path = p[0] if not history_path: history_path = p[1] apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap() if use_sqlite: from google.appengine.datastore import datastore_sqlite_stub stub = datastore_sqlite_stub.DatastoreSqliteStub(appid, datastore_path, history_path) else: stub = datastore_file_stub.DatastoreFileStub(appid, datastore_path, history_path) apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', stub) if use_ipython: try: import IPython except ImportError: pass else: sh = IPython.Shell.IPShellEmbed(argv='', banner=banner) sh(global_ns={}, local_ns=namespace) return sys.ps1 = '%s> ' % appid if readline is not None: readline.parse_and_bind('tab: complete') atexit.register(lambda: readline.write_history_file(HISTORY_PATH)) if os.path.exists(HISTORY_PATH): readline.read_history_file(HISTORY_PATH) from code import interact interact(banner, local=namespace)
def runserver_passthru_argv(): """ Execute dev_appserver with appropriate parameters. For more details, please invoke 'python manage.py runserver --help'. """ from google.appengine.tools import dev_appserver_main progname = "manage.py runserver" args = [] args.extend(sys.argv[2:]) p = get_datastore_paths() if not args_have_option(args, "--datastore_path"): args.extend(["--datastore_path", p[0]]) if not args_have_option(args, "--history_path"): args.extend(["--history_path", p[1]]) # Append the current working directory to the arguments. if "-h" in args or "--help" in args: render_dict = dev_appserver_main.DEFAULT_ARGS.copy() render_dict['script'] = "manage.py runserver" print_status(dev_appserver_main.__doc__ % render_dict) sys.stdout.flush() sys.exit(0) dev_appserver_main.main([progname] + args + [os.getcwdu()])