def run_from_argv(self, argv): from google.appengine.ext.remote_api import remote_api_stub from google.appengine.tools import appengine_rpc import getpass from djangae.boot import find_project_root self.stdout = OutputWrapper(sys.stdout) def auth_func(): return (raw_input('Google Account Login:'******'Password:'******'app.yaml')).read() app_id = app_yaml.split("application:")[1].lstrip().split()[0] self.stdout.write("Opening Remote API connection to {0}...\n".format(app_id)) remote_api_stub.ConfigureRemoteApi(None, '/_ah/remote_api', auth_func, servername='{0}.appspot.com'.format(app_id), secure=True, ) self.stdout.write("...Connection established...have a nice day :)\n".format(app_id)) argv = argv[:1] + argv[2:] execute_from_command_line(argv)
def run_from_argv(self, argv): from google.appengine.ext.remote_api import remote_api_stub from google.appengine.tools import appengine_rpc import getpass from djangae.boot import find_project_root self.stdout = OutputWrapper(sys.stdout) def auth_func(): return (raw_input('Google Account Login:'******'Password:'******'app.yaml')).read() app_id = app_yaml.split("application:")[1].lstrip().split()[0] self.stdout.write( "Opening Remote API connection to {0}...\n".format(app_id)) remote_api_stub.ConfigureRemoteApi( None, '/_ah/remote_api', auth_func, servername='{0}.appspot.com'.format(app_id), secure=True, ) self.stdout.write( "...Connection established...have a nice day :)\n".format(app_id)) argv = argv[:1] + argv[2:] execute_from_command_line(argv)
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 get_new_connection(self, conn_params): from google.appengine.datastore import datastore_stub_util from google.appengine.datastore import datastore_sqlite_stub from google.appengine.api import apiproxy_stub_map datastore_stub = datastore_sqlite_stub.DatastoreSqliteStub( "dev~" + application_id(), os.path.join(data_root(), 'datastore.db'), False, trusted=False, root_path=find_project_root(), auto_id_policy=datastore_stub_util.SCATTERED) datastore_stub.SetConsistencyPolicy( datastore_stub_util.PseudoRandomHRConsistencyPolicy()) apiproxy_stub_map.apiproxy.ReplaceStub('datastore_v3', datastore_stub) class FakeConnection: def commit(self): pass return FakeConnection()
def get_new_connection(self, conn_params): from google.appengine.datastore import datastore_stub_util from google.appengine.datastore import datastore_sqlite_stub from google.appengine.api import apiproxy_stub_map datastore_stub = datastore_sqlite_stub.DatastoreSqliteStub( "dev~" + application_id(), os.path.join(data_root(), 'datastore.db'), False, trusted=False, root_path=find_project_root(), auto_id_policy=datastore_stub_util.SCATTERED ) datastore_stub.SetConsistencyPolicy(datastore_stub_util.PseudoRandomHRConsistencyPolicy()) apiproxy_stub_map.apiproxy.ReplaceStub('datastore_v3', datastore_stub) class FakeConnection: def commit(self): pass return FakeConnection()
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)
def _get_index_file(): from djangae.boot import find_project_root index_file = os.path.join(find_project_root(), "djangaeidx.yaml") return index_file
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)