/ programming

Google App Engine 1.9.17 - removed old dev_appserver

If someone hasn’t switched yet to a new dev_appserver then since App Engine version 1.9.17 he can see errors like:

ImportError: No module named dev_appserver

or

ImportError: No module named old_dev_appserver

It happened because Google removed old dev_appserver and we should switch to a new one. In my case I've changed:

import os

try:
  from google.appengine.tools.dev_appserver import ReadAppConfig
except ImportError:
  from google.appengine.tools.old_dev_appserver import ReadAppConfig

config = ReadAppConfig(os.path.join(APP_PATH, 'app.yaml'))
os.environ['APPLICATION_ID'] = config.application

to:

import os

from google.appengine.tools.devappserver2 import application_configuration

config = application_configuration.ApplicationConfiguration(
    [os.path.join(APP_PATH, 'app.yaml')]
)
os.environ['APPLICATION_ID'] = config.app_id