def start_dev_appserver(): """Starts the appengine dev_appserver program for the Django project. The appserver is run with default parameters. If you need to pass any special parameters to the dev_appserver you will have to invoke it manually. """ from google.appengine.tools import dev_appserver_main progname = sys.argv[0] args = [] # hack __main__ so --help in dev_appserver_main works OK. sys.modules['__main__'] = dev_appserver_main # Set bind ip/port if specified. if len(sys.argv) > 2: addrport = sys.argv[2] try: addr, port = addrport.split(":") except ValueError: addr, port = None, addrport if not port.isdigit(): print "Error: '%s' is not a valid port number." % port sys.exit(1) else: addr, port = None, None if addr: args.extend(["--address", addr]) if port: args.extend(["--port", port]) # Pass the application specific datastore location to the server. p = get_datastore_paths() args.extend(["--datastore_path", p[0], "--history_path", p[1]]) # Append the current working directory to the arguments. dev_appserver_main.main([progname] + args + [os.getcwdu()])
def action_runserver(self, options, args): """launch 'dev_appserver.py runserver' """ self.setup_stubs(options) from google.appengine.tools import dev_appserver_main dev_appserver_main.main( ['runserver', '-a', options.address, '-p', options.port, '.'])
def action_runserver(self, options, args): """launch 'dev_appserver.py runserver' """ self.setup_stubs(options) from google.appengine.tools import dev_appserver_main dev_appserver_main.main(["runserver", "-a", options.address, "-p", options.port, "."])
def run_from_argv(self, argv): fixtures = argv[2:] # Ensure an on-disk test datastore is used. from django.db import connection connection.use_test_datastore = True connection.test_datastore_inmemory = False # Flush any existing test datastore. connection.flush() # Load the fixtures. from django.core.management import call_command call_command('loaddata', 'initial_data') if fixtures: call_command('loaddata', *fixtures) # Build new arguments for dev_appserver. datastore_path, history_path = get_test_datastore_paths(False) new_args = argv[0:1] new_args.extend(['--datastore_path', datastore_path]) new_args.extend(['--history_path', history_path]) new_args.extend([os.getcwdu()]) # Add email settings from django.conf import settings new_args.extend(['--smtp_host', settings.EMAIL_HOST, '--smtp_port', str(settings.EMAIL_PORT), '--smtp_user', settings.EMAIL_HOST_USER, '--smtp_password', settings.EMAIL_HOST_PASSWORD]) # Start the test dev_appserver. from google.appengine.tools import dev_appserver_main dev_appserver_main.main(new_args)
def start(port, address): """ Starts the appengine dev_appserver program. Here dev_appserver.py is run with a set of default parameters. To pass special parameters, run dev_appserver.py manually. """ from google.appengine.tools import dev_appserver_main args = [ '--address', address, '--port', port, '--require_indexes', '--skip_sdk_update_check', '--high_replication', '--default_partition=', '--datastore_path=.appname.ds', '--allow_skipped_files', '--debug', #'--backends', ] # Append the current working directory to the arguments. run_args = [None] run_args.extend(args) run_args.append(CURRENT_PATH) sys.modules['__main__'] = dev_appserver_main #hack __main__ so --help in dev_appserver_main works OK. dev_appserver_main.main(run_args)
def start(port, address): """ Starts the appengine dev_appserver program. Here dev_appserver.py is run with a set of default parameters. To pass special parameters, run dev_appserver.py manually. """ from google.appengine.tools import dev_appserver_main args = [ '--address', address, '--port', port, '--require_indexes', '--skip_sdk_update_check', '--high_replication', '--default_partition=', '--datastore_path=.demo.ds', '--allow_skipped_files', '--debug', #'--backends', ] # Append the current working directory to the arguments. run_args = [None] run_args.extend(args) run_args.append(CURRENT_PATH) sys.modules['__main__'] = dev_appserver_main #hack __main__ so --help in dev_appserver_main works OK. dev_appserver_main.main(run_args)
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 run(self, *args, **options): """ Starts the App Engine dev_appserver program for the Django project. The appserver is run with default parameters. If you need to pass any special parameters to the dev_appserver you will have to invoke it manually. Unlike the normal devserver, does not use the autoreloader as App Engine dev_appserver needs to be run from the main thread """ args = [] # Set bind ip/port if specified. if self.addr: args.extend(["--address", self.addr]) if self.port: args.extend(["--port", self.port]) # Add email settings from django.conf import settings if not options.get('smtp_host', None) and not options.get('enable_sendmail', None): args.extend(['--smtp_host', settings.EMAIL_HOST, '--smtp_port', str(settings.EMAIL_PORT), '--smtp_user', settings.EMAIL_HOST_USER, '--smtp_password', settings.EMAIL_HOST_PASSWORD]) # Pass the application specific datastore location to the server. for name in connections: connection = connections[name] if isinstance(connection, DatabaseWrapper): for key, path in get_datastore_paths(connection.settings_dict).items(): # XXX/TODO: Remove this when SDK 1.4.3 is released if key == 'prospective_search_path': continue arg = '--' + key if arg not in args: args.extend([arg, path]) break # Process the rest of the options here bool_options = ['debug', 'debug_imports', 'clear_datastore', 'require_indexes', 'high_replication', 'enable_sendmail', ] for opt in bool_options: if options[opt] != False: args.append("--%s" % opt) str_options = ['datastore_path', 'history_path', 'login_url', 'smtp_host', 'smtp_port', 'smtp_user', 'smtp_password',] for opt in str_options: if options.get(opt, None) != None: args.extend(["--%s" % opt, options[opt]]) # Reset logging level to INFO as dev_appserver will spew tons of debug logs logging.getLogger().setLevel(logging.INFO) # Append the current working directory to the arguments. dev_appserver_main.main([self.progname] + args + [PROJECT_DIR])
def run_from_argv(self, argv): dev_appserver_main.PrintUsageExit = lambda x: "" # this is crap, things like this will lead you to problems # only to keep compatibility with Django default 8000 port if not any(arg.startswith("--port=") or "-p" == arg for arg in argv): argv.append("--port=8000") dev_appserver_main.main(['runserver', PROJECT_DIR] + argv[2:])
def run_from_argv(self, argv): dev_appserver_main.PrintUsageExit = lambda x: "" # this is crap, things like this will lead you to problems # only to keep compatibility with Django default 8000 port if not any( arg.startswith("--port=") or "-p" == arg for arg in argv ): argv.append("--port=8000") dev_appserver_main.main(['runserver', PROJECT_DIR] + argv[2:])
def start_dev_appserver(argv): """Starts the App Engine dev_appserver program for the Django project. The appserver is run with default parameters. If you need to pass any special parameters to the dev_appserver you will have to invoke it manually. """ from google.appengine.tools import dev_appserver_main progname = argv[0] args = [] # hack __main__ so --help in dev_appserver_main works OK. sys.modules['__main__'] = dev_appserver_main # Set bind ip/port if specified. addr, port = None, '8000' if len(argv) > 2: if not argv[2].startswith('-'): addrport = argv[2] try: addr, port = addrport.split(":") except ValueError: addr = addrport else: args.append(argv[2]) args.extend(argv[3:]) if addr: args.extend(["--address", addr]) if port: args.extend(["--port", port]) # Add email settings from django.conf import settings if '--smtp_host' not in args and '--enable_sendmail' not in args: args.extend([ '--smtp_host', settings.EMAIL_HOST, '--smtp_port', str(settings.EMAIL_PORT), '--smtp_user', settings.EMAIL_HOST_USER, '--smtp_password', settings.EMAIL_HOST_PASSWORD ]) # Pass the application specific datastore location to the server. for name in connections: connection = connections[name] if isinstance(connection, DatabaseWrapper): p = connection._get_paths() if '--datastore_path' not in args: args.extend(['--datastore_path', p[0]]) if '--blobstore_path' not in args: args.extend(['--blobstore_path', p[1]]) if '--history_path' not in args: args.extend(['--history_path', p[2]]) break # Reset logging level to INFO as dev_appserver will spew tons of debug logs logging.getLogger().setLevel(logging.INFO) # Append the current working directory to the arguments. dev_appserver_main.main([progname] + args + [PROJECT_DIR])
def start_dev_appserver(argv): """Starts the App Engine dev_appserver program for the Django project. The appserver is run with default parameters. If you need to pass any special parameters to the dev_appserver you will have to invoke it manually. """ from google.appengine.tools import dev_appserver_main progname = argv[0] args = [] # hack __main__ so --help in dev_appserver_main works OK. sys.modules['__main__'] = dev_appserver_main # Set bind ip/port if specified. addr, port = None, '8000' if len(argv) > 2: if not argv[2].startswith('-'): addrport = argv[2] try: addr, port = addrport.split(":") except ValueError: addr = addrport else: args.append(argv[2]) args.extend(argv[3:]) if addr: args.extend(["--address", addr]) if port: args.extend(["--port", port]) # Add email settings from django.conf import settings if '--smtp_host' not in args and '--enable_sendmail' not in args: args.extend(['--smtp_host', settings.EMAIL_HOST, '--smtp_port', str(settings.EMAIL_PORT), '--smtp_user', settings.EMAIL_HOST_USER, '--smtp_password', settings.EMAIL_HOST_PASSWORD]) # Pass the application specific datastore location to the server. for name in connections: connection = connections[name] if isinstance(connection, DatabaseWrapper): for key, path in get_datastore_paths(connection.settings_dict).items(): # XXX/TODO: Remove this when SDK 1.4.3 is released if key == 'prospective_search_path': continue arg = '--' + key if arg not in args: args.extend([arg, path]) break # Reset logging level to INFO as dev_appserver will spew tons of debug logs logging.getLogger().setLevel(logging.INFO) # Append the current working directory to the arguments. dev_appserver_main.main([progname] + args + [PROJECT_DIR])
def start_dev_appserver(): """Starts the appengine dev_appserver program for the Django project. The appserver is run with default parameters. If you need to pass any special parameters to the dev_appserver you will have to invoke it manually. """ from google.appengine.tools import dev_appserver_main progname = sys.argv[0] args = [] # hack __main__ so --help in dev_appserver_main works OK. sys.modules['__main__'] = dev_appserver_main # Set bind ip/port if specified. if len(sys.argv) > 2 and not sys.argv[2].startswith("--"): addrport = sys.argv[2] try: addr, port = addrport.split(":") except ValueError: addr, port = None, addrport if not port.isdigit(): print "Error: '%s' is not a valid port number." % port sys.exit(1) else: addr, port = None, "8000" if addr: args.extend(["--address", addr]) if port: args.extend(["--port", port]) # Add email settings from django.conf import settings args.extend(['--smtp_host', settings.EMAIL_HOST, '--smtp_port', str(settings.EMAIL_PORT), '--smtp_user', settings.EMAIL_HOST_USER, '--smtp_password', settings.EMAIL_HOST_PASSWORD]) # Allow skipped files so we don't die args.extend(['--allow_skipped_files']) # Pass the application specific datastore location to the server. p = get_datastore_paths() datastore_path = p[0] history_path = p[1] if len(sys.argv) > 2: for arg in sys.argv[2:]: if arg.startswith("--datastore_path="): datastore_path=arg[arg.index("=")+1:] elif arg.startswith("--history_path="): history_path = arg[arg.index("=")+1:] args.extend(["--datastore_path", datastore_path, "--history_path", history_path]) # Append the current working directory to the arguments. dev_appserver_main.main([progname] + args + [os.getcwdu()])
def start_dev_appserver(argv): """Starts the App Engine dev_appserver program for the Django project. The appserver is run with default parameters. If you need to pass any special parameters to the dev_appserver you will have to invoke it manually. """ from google.appengine.tools import dev_appserver_main progname = argv[0] args = [] # hack __main__ so --help in dev_appserver_main works OK. sys.modules['__main__'] = dev_appserver_main # Set bind ip/port if specified. addr, port = None, '8000' if len(argv) > 2: if not argv[2].startswith('-'): addrport = argv[2] try: addr, port = addrport.split(":") except ValueError: addr, port = None, addrport if not port.isdigit(): print "Error: '%s' is not a valid port number." % port sys.exit(1) else: args.append(argv[2]) args.extend(argv[3:]) if addr: args.extend(["--address", addr]) if port: args.extend(["--port", port]) # Add email settings from django.conf import settings if '--smtp_host' not in args and '--enable_sendmail' not in args: args.extend(['--smtp_host', settings.EMAIL_HOST, '--smtp_port', str(settings.EMAIL_PORT), '--smtp_user', settings.EMAIL_HOST_USER, '--smtp_password', settings.EMAIL_HOST_PASSWORD]) # Pass the application specific datastore location to the server. p = connection._get_paths() if '--datastore_path' not in args: args.extend(['--datastore_path', p[0]]) if '--blobstore_path' not in args: args.extend(['--blobstore_path', p[1]]) if '--history_path' not in args: args.extend(['--history_path', p[2]]) # Reset logging level to INFO as dev_appserver will spew tons of debug logs logging.getLogger().setLevel(logging.INFO) # Append the current working directory to the arguments. dev_appserver_main.main([progname] + args + [os.getcwdu()])
def start_dev_appserver(): """Starts the appengine dev_appserver program for the Django project. The appserver is run with default parameters. If you need to pass any special parameters to the dev_appserver you will have to invoke it manually. """ from google.appengine.tools import dev_appserver_main progname = sys.argv[0] args = [] # hack __main__ so --help in dev_appserver_main works OK. sys.modules['__main__'] = dev_appserver_main # Set bind ip/port if specified. if len(sys.argv) > 2: addrport = sys.argv[2] try: addr, port = addrport.split(":") except ValueError: addr, port = None, addrport if not port.isdigit(): print "Error: '%s' is not a valid port number." % port sys.exit(1) else: addr, port = None, "8000" if addr: args.extend(["--address", addr]) if port: args.extend(["--port", port]) # Add email settings from django.conf import settings args.extend([ '--smtp_host', settings.EMAIL_HOST, '--smtp_port', str(settings.EMAIL_PORT), '--smtp_user', settings.EMAIL_HOST_USER, '--smtp_password', settings.EMAIL_HOST_PASSWORD ]) # Allow skipped files so we don't die args.extend(['--allow_skipped_files']) # Pass the application specific datastore location to the server. p = get_datastore_paths() args.extend(["--datastore_path", p[0], "--history_path", p[1]]) # Append the current working directory to the arguments. dev_appserver_main.main([progname] + args + [os.getcwdu()])
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()])
def run(self, *args, **options): """ Starts the App Engine dev_appserver program for the Django project. The appserver is run with default parameters. If you need to pass any special parameters to the dev_appserver you will have to invoke it manually. Unlike the normal devserver, does not use the autoreloader as App Engine dev_appserver needs to be run from the main thread """ args = [] # Set bind ip/port if specified. if self.addr: args.extend(['--address', self.addr]) if self.port: args.extend(['--port', self.port]) # If runserver is called using handle(), progname will not be # set. if not hasattr(self, 'progname'): self.progname = 'manage.py' # Add email settings. from django.conf import settings if not options.get('smtp_host', None) and \ not options.get('enable_sendmail', None): args.extend([ '--smtp_host', settings.EMAIL_HOST, '--smtp_port', str(settings.EMAIL_PORT), '--smtp_user', settings.EMAIL_HOST_USER, '--smtp_password', settings.EMAIL_HOST_PASSWORD ]) # Pass the application specific datastore location to the # server. preset_options = {} for name in connections: connection = connections[name] if isinstance(connection, DatabaseWrapper): for key, path in get_datastore_paths( connection.settings_dict).items(): # XXX/TODO: Remove this when SDK 1.4.3 is released. if key == 'prospective_search_path': continue arg = '--' + key if arg not in args: args.extend([arg, path]) # Get dev_appserver option presets, to be applied below. preset_options = connection.settings_dict.get( 'DEV_APPSERVER_OPTIONS', {}) break # Process the rest of the options here. bool_options = [ 'debug', 'debug_imports', 'clear_datastore', 'require_indexes', 'high_replication', 'enable_sendmail', 'use_sqlite', 'allow_skipped_files', 'disable_task_running', ] for opt in bool_options: if options[opt] != False: args.append('--%s' % opt) str_options = [ 'datastore_path', 'history_path', 'login_url', 'smtp_host', 'smtp_port', 'smtp_user', 'smtp_password', ] for opt in str_options: if options.get(opt, None) != None: args.extend(['--%s' % opt, options[opt]]) # Fill any non-overridden options with presets from settings. for opt, value in preset_options.items(): arg = '--%s' % opt if arg not in args: if value and opt in bool_options: args.append(arg) elif opt in str_options: args.extend([arg, value]) # TODO: Issue warning about bogus option key(s)? # Reset logging level to INFO as dev_appserver will spew tons # of debug logs. logging.getLogger().setLevel(logging.INFO) # Append the current working directory to the arguments. dev_appserver_main.main([self.progname] + args + [PROJECT_DIR])
def run_from_argv(self, argv): dev_appserver_main.PrintUsageExit = lambda x: "" dev_appserver_main.main(["runserver", PROJECT_DIR] + argv[2:] + ["--port=8000"])
def run_from_argv(self, argv): port = ['--port=%s' % DEFAULT_PORT] if argv: port = [arg for arg in argv if 'port' in arg] dev_appserver_main.PrintUsageExit = lambda x: "" dev_appserver_main.main(['runserver', PROJECT_DIR] + argv[2:] + port)
def run(self, *args, **options): """ Starts the App Engine dev_appserver program for the Django project. The appserver is run with default parameters. If you need to pass any special parameters to the dev_appserver you will have to invoke it manually. Unlike the normal devserver, does not use the autoreloader as App Engine dev_appserver needs to be run from the main thread """ args = [] # Set bind ip/port if specified. if self.addr: args.extend(["--address", self.addr]) if self.port: args.extend(["--port", self.port]) # If runserver is called using handle(), progname will not be set if not hasattr(self, 'progname'): self.progname = "manage.py" # Add email settings from django.conf import settings if not options.get('smtp_host', None) and not options.get( 'enable_sendmail', None): args.extend([ '--smtp_host', settings.EMAIL_HOST, '--smtp_port', str(settings.EMAIL_PORT), '--smtp_user', settings.EMAIL_HOST_USER, '--smtp_password', settings.EMAIL_HOST_PASSWORD ]) # Pass the application specific datastore location to the server. for name in connections: connection = connections[name] if isinstance(connection, DatabaseWrapper): for key, path in get_datastore_paths( connection.settings_dict).items(): # XXX/TODO: Remove this when SDK 1.4.3 is released if key == 'prospective_search_path': continue arg = '--' + key if arg not in args: args.extend([arg, path]) break # Process the rest of the options here bool_options = [ 'debug', 'debug_imports', 'clear_datastore', 'require_indexes', 'high_replication', 'enable_sendmail', ] for opt in bool_options: if options[opt] != False: args.append("--%s" % opt) str_options = [ 'datastore_path', 'history_path', 'login_url', 'smtp_host', 'smtp_port', 'smtp_user', 'smtp_password', ] for opt in str_options: if options.get(opt, None) != None: args.extend(["--%s" % opt, options[opt]]) # Reset logging level to INFO as dev_appserver will spew tons of debug logs logging.getLogger().setLevel(logging.INFO) # Append the current working directory to the arguments. dev_appserver_main.main([self.progname] + args + [PROJECT_DIR])
def start_dev_appserver(argv): """Starts the App Engine dev_appserver program for the Django project. The appserver is run with default parameters. If you need to pass any special parameters to the dev_appserver you will have to invoke it manually. """ from google.appengine.tools import dev_appserver_main progname = argv[0] args = [] # hack __main__ so --help in dev_appserver_main works OK. sys.modules['__main__'] = dev_appserver_main # Set bind ip/port if specified. addr, port = None, '8000' if len(argv) > 2: if not argv[2].startswith('-'): addrport = argv[2] try: addr, port = addrport.split(":") except ValueError: addr, port = None, addrport if not port.isdigit(): print "Error: '%s' is not a valid port number." % port sys.exit(1) else: args.append(argv[2]) args.extend(argv[3:]) if addr: args.extend(["--address", addr]) if port: args.extend(["--port", port]) # Add email settings from django.conf import settings if '--smtp_host' not in args and '--enable_sendmail' not in args: args.extend([ '--smtp_host', settings.EMAIL_HOST, '--smtp_port', str(settings.EMAIL_PORT), '--smtp_user', settings.EMAIL_HOST_USER, '--smtp_password', settings.EMAIL_HOST_PASSWORD ]) # Pass the application specific datastore location to the server. p = connection._get_paths() if '--datastore_path' not in args: args.extend(['--datastore_path', p[0]]) if '--blobstore_path' not in args: args.extend(['--blobstore_path', p[1]]) if '--history_path' not in args: args.extend(['--history_path', p[2]]) # Reset logging level to INFO as dev_appserver will spew tons of debug logs logging.getLogger().setLevel(logging.INFO) # Allow to run subprocesses from google.appengine.tools import dev_appserver try: env = dev_appserver.DEFAULT_ENV dev_appserver.DEFAULT_ENV = os.environ.copy() dev_appserver.DEFAULT_ENV.update(env) except AttributeError: logging.warn('Could not patch the default environment. ' 'The subprocess module will not work correctly.') # Append the current working directory to the arguments. dev_appserver_main.main([progname] + args + [os.getcwdu()])
def start_dev_appserver(argv): """Starts the App Engine dev_appserver program for the Django project. The appserver is run with default parameters. If you need to pass any special parameters to the dev_appserver you will have to invoke it manually. """ from google.appengine.tools import dev_appserver_main progname = argv[0] args = [] # hack __main__ so --help in dev_appserver_main works OK. sys.modules['__main__'] = dev_appserver_main # Set bind ip/port if specified. addr, port = None, '8000' if len(argv) > 2: if not argv[2].startswith('-'): addrport = argv[2] try: addr, port = addrport.split(":") except ValueError: addr = addrport else: args.append(argv[2]) args.extend(argv[3:]) if addr: args.extend(["--address", addr]) if port: args.extend(["--port", port]) # Add email settings from django.conf import settings if '--smtp_host' not in args and '--enable_sendmail' not in args: args.extend(['--smtp_host', settings.EMAIL_HOST, '--smtp_port', str(settings.EMAIL_PORT), '--smtp_user', settings.EMAIL_HOST_USER, '--smtp_password', settings.EMAIL_HOST_PASSWORD]) # Pass the application specific datastore location to the server. for name in connections: connection = connections[name] if isinstance(connection, DatabaseWrapper): p = connection._get_paths() if '--datastore_path' not in args: args.extend(['--datastore_path', p[0]]) if '--blobstore_path' not in args: args.extend(['--blobstore_path', p[1]]) if '--history_path' not in args: args.extend(['--history_path', p[2]]) break # Reset logging level to INFO as dev_appserver will spew tons of debug logs logging.getLogger().setLevel(logging.INFO) # Allow to run subprocesses from google.appengine.tools import dev_appserver try: env = dev_appserver.DEFAULT_ENV dev_appserver.DEFAULT_ENV = os.environ.copy() dev_appserver.DEFAULT_ENV.update(env) except AttributeError: logging.warn('Could not patch the default environment. ' 'The subprocess module will not work correctly.') # Allow to use the compiler module try: dev_appserver.HardenedModulesHook._WHITE_LIST_C_MODULES.append('parser') except AttributeError: logging.warn('Could not patch modules whitelist. ' 'The compiler and parser modules will not work.') # Append the current working directory to the arguments. dev_appserver_main.main([progname] + args + [os.getcwdu()])
#!/usr/bin/env python # To change this template, choose Tools | Templates # and open the template in the editor. from google.appengine.tools.dev_appserver_main import main import os import sys if __name__ == "__main__": arg = [os.curdir, "."] sys.exit(main(arg))
def run(self, *args, **options): """ Starts the App Engine dev_appserver program for the Django project. The appserver is run with default parameters. If you need to pass any special parameters to the dev_appserver you will have to invoke it manually. Unlike the normal devserver, does not use the autoreloader as App Engine dev_appserver needs to be run from the main thread """ args = [] # Set bind ip/port if specified. if self.addr: args.extend(["--address", self.addr]) if self.port: args.extend(["--port", self.port]) # If runserver is called using handle(), progname will not be set if not hasattr(self, 'progname'): self.progname = "manage.py" # Add email settings from django.conf import settings if not options.get('smtp_host', None) and not options.get('enable_sendmail', None): args.extend(['--smtp_host', settings.EMAIL_HOST, '--smtp_port', str(settings.EMAIL_PORT), '--smtp_user', settings.EMAIL_HOST_USER, '--smtp_password', settings.EMAIL_HOST_PASSWORD]) # Pass the application specific datastore location to the server. preset_options = {} for name in connections: connection = connections[name] if isinstance(connection, DatabaseWrapper): for key, path in get_datastore_paths(connection.settings_dict).items(): # XXX/TODO: Remove this when SDK 1.4.3 is released if key == 'prospective_search_path': continue arg = '--' + key if arg not in args: args.extend([arg, path]) # Get dev_appserver option presets, to be applied below preset_options = connection.settings_dict.get('DEV_APPSERVER_OPTIONS', {}) break # Process the rest of the options here bool_options = ['debug', 'debug_imports', 'clear_datastore', 'require_indexes', 'high_replication', 'enable_sendmail', 'use_sqlite', 'allow_skipped_files','disable_task_running', ] for opt in bool_options: if options[opt] != False: args.append("--%s" % opt) str_options = ['datastore_path', 'history_path', 'login_url', 'smtp_host', 'smtp_port', 'smtp_user', 'smtp_password',] for opt in str_options: if options.get(opt, None) != None: args.extend(["--%s" % opt, options[opt]]) # Fill any non-overridden options with presets from settings for opt, value in preset_options.items(): arg = "--%s" % opt if arg not in args: if value and opt in bool_options: args.append(arg) elif opt in str_options: args.extend([arg, value]) # TODO: issue warning about bogus option key(s)? # Reset logging level to INFO as dev_appserver will spew tons of debug logs logging.getLogger().setLevel(logging.INFO) # Append the current working directory to the arguments. dev_appserver_main.main([self.progname] + args + [PROJECT_DIR])
def run(self, *args, **options): """ Starts the App Engine dev_appserver program for the Django project. The appserver is run with default parameters. If you need to pass any special parameters to the dev_appserver you will have to invoke it manually. Unlike the normal devserver, does not use the autoreloader as App Engine dev_appserver needs to be run from the main thread """ args = [] # Set bind ip/port if specified. if self.addr: if settings.DEV_APPSERVER_VERSION == 1: args.extend(['--address', self.addr]) else: args.extend(['--host', self.addr]) if self.port: if settings.DEV_APPSERVER_VERSION == 1: args.extend(['--port', self.port]) else: args.extend(['--port', self.port if self.port != DEFAULT_PORT else DEV_APPSERVER_V2_DEFAULT_PORT]) # If runserver is called using handle(), progname will not be # set. if not hasattr(self, 'progname'): self.progname = 'manage.py' # Add email settings. if not options.get('smtp_host', None) and \ not options.get('enable_sendmail', None): args.extend(['--smtp_host', settings.EMAIL_HOST, '--smtp_port', str(settings.EMAIL_PORT), '--smtp_user', settings.EMAIL_HOST_USER, '--smtp_password', settings.EMAIL_HOST_PASSWORD]) # Pass the application specific datastore location to the # server. preset_options = {} for name in connections: connection = connections[name] if isinstance(connection, DatabaseWrapper): for key, path in get_datastore_paths(connection.settings_dict).items(): arg = '--' + key if arg not in args: args.extend([arg, path]) # Get dev_appserver option presets, to be applied below. preset_options = connection.settings_dict.get('DEV_APPSERVER_OPTIONS', {}) break # Process the rest of the options here. if settings.DEV_APPSERVER_VERSION == 1: bool_options = [ 'debug', 'debug_imports', 'clear_datastore', 'require_indexes', 'high_replication', 'enable_sendmail', 'use_sqlite', 'allow_skipped_files', 'disable_task_running'] else: bool_options = [ 'debug', 'debug_imports', 'clear_datastore', 'require_indexes', 'enable_sendmail', 'allow_skipped_files', 'disable_task_running'] for opt in bool_options: if options[opt] != False: if settings.DEV_APPSERVER_VERSION == 1: args.append('--%s' % opt) else: args.extend(['--%s' % opt, 'yes']) str_options = [ 'datastore_path', 'blobstore_path', 'history_path', 'login_url', 'smtp_host', 'smtp_port', 'smtp_user', 'smtp_password', 'auto_id_policy'] for opt in str_options: if options.get(opt, None) != None: args.extend(['--%s' % opt, options[opt]]) # Fill any non-overridden options with presets from settings. for opt, value in preset_options.items(): arg = '--%s' % opt if arg not in args: if value and opt in bool_options: if settings.DEV_APPSERVER_VERSION == 1: args.append(arg) else: args.extend([arg, value]) elif opt in str_options: args.extend([arg, value]) # TODO: Issue warning about bogus option key(s)? # Reset logging level to INFO as dev_appserver will spew tons # of debug logs. logging.getLogger().setLevel(logging.INFO) # Append the current working directory to the arguments. if settings.DEV_APPSERVER_VERSION == 1: dev_appserver_main.main([self.progname] + args + [PROJECT_DIR]) else: from google.appengine.api import apiproxy_stub_map # Environment is set in djangoappengine.stubs.setup_local_stubs() # We need to do this effectively reset the stubs. apiproxy_stub_map.apiproxy = apiproxy_stub_map.GetDefaultAPIProxy() sys.argv = ['/home/user/google_appengine/devappserver2.py'] + args + [PROJECT_DIR] devappserver2.main()