def __init__(self, *args, **kwds): super(DatabaseWrapper, self).__init__(*args, **kwds) setup_paths() #Make sure we can find appengine self.features = DatabaseFeatures(self) self.ops = DatabaseOperations(self) self.client = DatabaseClient(self) self.creation = DatabaseCreation(self) self.validation = DatabaseValidation(self) self.introspection = DatabaseIntrospection(self) options = self.settings_dict self.remote_app_id = options.get('REMOTE_APP_ID', application_id()) self.domain = options.get('DOMAIN', 'appspot.com') self.remote_api_path = options.get('REMOTE_API_PATH', None) self.secure_remote_api = options.get('SECURE_REMOTE_API', True) from google.appengine.api import datastore_errors class DatabaseErrors(object): DataError = datastore_errors.BadValueError OperationalError = datastore_errors.InternalError IntegrityError = datastore_errors.Error InternalError = datastore_errors.InternalError ProgrammingError = datastore_errors.BadRequestError NotSupportedError = datastore_errors.BadQueryError DatabaseError = datastore_errors.InternalError InterfaceError = datastore_errors.InternalError Error = datastore_errors.Error self.Database = DatabaseErrors
def __init__(self, *args, **kwargs): from djangae.boot import setup_paths,setup_datastore_stubs setup_paths() setup_datastore_stubs() super(Command, self).__init__(*args, **kwargs)
def __init__(self, *args, **kwargs): from djangae.boot import setup_paths, setup_datastore_stubs setup_paths() setup_datastore_stubs() super(Command, self).__init__(*args, **kwargs)
def handle(self, *args, **options): shutdown_message = options.get('shutdown_message', '') application = options.get('application') version = options.get('version') from djangae.boot import setup_paths, find_project_root setup_paths() project_root = find_project_root() expected_path = os.path.join(project_root, "app.yaml") if not os.path.exists(expected_path): sys.stderr.write("Unable to find app.yaml at '%s'\n" % expected_path) sys.exit(1) # Will have been set by setup_paths sdk_path = os.environ['APP_ENGINE_SDK'] appcfg = os.path.join(sdk_path, "appcfg.py") # very simple for now, only runs appcfg.py update . and some # extra parameters like app id or version command = [ appcfg, "update", project_root ] if application: command += ["-A", application] if version: command += ["-V", version] process = Popen( command, stdout=sys.__stdout__, stderr=sys.__stderr__, cwd=project_root ) try: process.wait() except KeyboardInterrupt: #Tell the dev appserver to shutdown and forcibly kill #if it takes too long process.send_signal(signal.SIGTERM) time.sleep(2) process.kill() if shutdown_message: sys.stdout.write(shutdown_message) sys.exit(process.returncode)
def handle(self, *args, **options): shutdown_message = options.get('shutdown_message', '') application = options.get('application') version = options.get('version') from djangae.boot import setup_paths, find_project_root setup_paths() project_root = find_project_root() expected_path = os.path.join(project_root, "app.yaml") if not os.path.exists(expected_path): sys.stderr.write("Unable to find app.yaml at '%s'\n" % expected_path) sys.exit(1) # Will have been set by setup_paths sdk_path = os.environ['APP_ENGINE_SDK'] appcfg = os.path.join(sdk_path, "appcfg.py") # very simple for now, only runs appcfg.py update . and some # extra parameters like app id or version command = [appcfg, "update", project_root] if application: command += ["-A", application] if version: command += ["-V", version] process = Popen(command, stdout=sys.__stdout__, stderr=sys.__stderr__, cwd=project_root) try: process.wait() except KeyboardInterrupt: #Tell the dev appserver to shutdown and forcibly kill #if it takes too long process.send_signal(signal.SIGTERM) time.sleep(2) process.kill() if shutdown_message: sys.stdout.write(shutdown_message) sys.exit(process.returncode)
def inner_run(self, *args, **options): import sys shutdown_message = options.get('shutdown_message', '') use_old_dev_appserver = options.get('use_old_dev_appserver') quit_command = 'CTRL-BREAK' if sys.platform == 'win32' else 'CONTROL-C' from djangae.boot import setup_paths, find_project_root, data_root setup_paths() from django.conf import settings from django.utils import translation #Check for app.yaml expected_path = os.path.join(find_project_root(), "app.yaml") if not os.path.exists(expected_path): sys.stderr.write("Unable to find app.yaml at '%s'\n" % expected_path) sys.exit(1) self.stdout.write("Validating models...\n\n") self.validate(display_num_errors=True) self.stdout.write( ("%(started_at)s\n" "Django version %(version)s, using settings %(settings)r\n" "Starting development server at http://%(addr)s:%(port)s/\n" "Quit the server with %(quit_command)s.\n") % { "started_at": datetime.now().strftime('%B %d, %Y - %X'), "version": self.get_version(), "settings": settings.SETTINGS_MODULE, "addr": self._raw_ipv6 and '[%s]' % self.addr or self.addr, "port": self.port, "quit_command": quit_command, }) sys.stdout.write("\n") sys.stdout.flush() # django.core.management.base forces the locale to en-us. We should # set it up correctly for the first request (particularly important # in the "--noreload" case). translation.activate(settings.LANGUAGE_CODE) #Will have been set by setup_paths sdk_path = os.environ['APP_ENGINE_SDK'] if use_old_dev_appserver: dev_appserver = os.path.join(sdk_path, "old_dev_appserver.py") command = [ dev_appserver, find_project_root(), "-p", self.port, "--use_sqlite", "--high_replication", "--allow_skipped_files", "--datastore_path", os.path.join(data_root(), "datastore.db") ] else: dev_appserver = os.path.join(sdk_path, "dev_appserver.py") command = [ dev_appserver, find_project_root(), "--port", self.port, "--storage_path", data_root(), "--admin_port", str(int(self.port) + 1), "--automatic_restart", "False", "--allow_skipped_files" ] process = Popen(command, stdout=sys.__stdout__, stderr=sys.__stderr__, cwd=find_project_root()) #This makes sure that dev_appserver gets killed on reload import atexit atexit.register(process.kill) try: process.wait() except KeyboardInterrupt: #Tell the dev appserver to shutdown and forcibly kill #if it takes too long process.send_signal(signal.SIGTERM) time.sleep(2) process.kill() if shutdown_message: sys.stdout.write(shutdown_message) #Some weird race condition crazy sometimes makes this None... if sys: sys.exit(process.returncode)
#!/usr/bin/env python import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testapp.settings") from djangae.boot import setup_paths setup_paths() from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)
def inner_run(self, *args, **options): import sys shutdown_message = options.get('shutdown_message', '') use_old_dev_appserver = options.get('use_old_dev_appserver') quit_command = 'CTRL-BREAK' if sys.platform == 'win32' else 'CONTROL-C' from djangae.boot import setup_paths, find_project_root, data_root setup_paths() from django.conf import settings from django.utils import translation #Check for app.yaml expected_path = os.path.join(find_project_root(), "app.yaml") if not os.path.exists(expected_path): sys.stderr.write("Unable to find app.yaml at '%s'\n" % expected_path) sys.exit(1) self.stdout.write("Validating models...\n\n") self.validate(display_num_errors=True) self.stdout.write(( "%(started_at)s\n" "Django version %(version)s, using settings %(settings)r\n" "Starting development server at http://%(addr)s:%(port)s/\n" "Quit the server with %(quit_command)s.\n" ) % { "started_at": datetime.now().strftime('%B %d, %Y - %X'), "version": self.get_version(), "settings": settings.SETTINGS_MODULE, "addr": self._raw_ipv6 and '[%s]' % self.addr or self.addr, "port": self.port, "quit_command": quit_command, }) sys.stdout.write("\n") sys.stdout.flush() # django.core.management.base forces the locale to en-us. We should # set it up correctly for the first request (particularly important # in the "--noreload" case). translation.activate(settings.LANGUAGE_CODE) #Will have been set by setup_paths sdk_path = os.environ['APP_ENGINE_SDK'] if use_old_dev_appserver: dev_appserver = os.path.join(sdk_path, "old_dev_appserver.py") command = [ dev_appserver, find_project_root(), "-p", self.port, "--use_sqlite", "--high_replication", "--allow_skipped_files", "--datastore_path", os.path.join(data_root(), "datastore.db") ] else: dev_appserver = os.path.join(sdk_path, "dev_appserver.py") command = [ dev_appserver, find_project_root(), "--port", self.port, "--storage_path", data_root(), "--admin_port", str(int(self.port) + 1), "--automatic_restart", "False", "--allow_skipped_files" ] process = Popen( command, stdout=sys.__stdout__, stderr=sys.__stderr__, cwd=find_project_root() ) #This makes sure that dev_appserver gets killed on reload import atexit atexit.register(process.kill) try: process.wait() except KeyboardInterrupt: #Tell the dev appserver to shutdown and forcibly kill #if it takes too long process.send_signal(signal.SIGTERM) time.sleep(2) process.kill() if shutdown_message: sys.stdout.write(shutdown_message) #Some weird race condition crazy sometimes makes this None... if sys: sys.exit(process.returncode)