files.new_contents: #!/usr/bin/env python
  #
  # Copyright 2007 Google Inc.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  #
  
  
  
  
  """An apiproxy stub that calls a remote handler via HTTP.
  
  This allows easy remote access to the App Engine datastore, and potentially any
  of the other App Engine APIs, using the same interface you use when accessing
  the service locally.
  
  An example Python script:
  ---
  from google.appengine.ext import db
  from google.appengine.ext.remote_api import remote_api_stub
  from myapp import models
  import getpass
  
  def auth_func():
    return (raw_input('Username:'), getpass.getpass('Password:'))
  
  remote_api_stub.ConfigureRemoteApi(None, '/_ah/remote_api', auth_func,
                                     'my-app.appspot.com')
  
  # Now you can access the remote datastore just as if your code was running on
  # App Engine!
  
  houses = models.House.all().fetch(100)
  for a_house in q:
    a_house.doors += 1
  db.put(houses)
  ---
  
  A few caveats:
  - Where possible, avoid iterating over queries. Fetching as many results as you
    will need is faster and more efficient. If you don't know how many results
    you need, or you need 'all of them', iterating is fine.
  - Likewise, it's a good idea
  
  [... the rest is omitted ...]
files.new_path: AppServer/google/appengine/ext/remote_api/remote_api_stub.py
files.old_contents: #!/usr/bin/env python
  #
  # Copyright 2007 Google Inc.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  #
  
  
  
  
  """An apiproxy stub that calls a remote handler via HTTP.
  
  This allows easy remote access to the App Engine datastore, and potentially any
  of the other App Engine APIs, using the same interface you use when accessing
  the service locally.
  
  An example Python script:
  ---
  from google.appengine.ext import db
  from google.appengine.ext.remote_api import remote_api_stub
  from myapp import models
  import getpass
  
  def auth_func():
    return (raw_input('Username:'), getpass.getpass('Password:'))
  
  remote_api_stub.ConfigureRemoteApi(None, '/_ah/remote_api', auth_func,
                                     'my-app.appspot.com')
  
  # Now you can access the remote datastore just as if your code was running on
  # App Engine!
  
  houses = models.House.all().fetch(100)
  for a_house in q:
    a_house.doors += 1
  db.put(houses)
  ---
  
  A few caveats:
  - Where possible, avoid iterating over queries. Fetching as many results as you
    will need is faster and more efficient. If you don't know how many results
    you need, or you need 'all of them', iterating is fine.
  - Likewise, it's a good idea
  
  [... the rest is omitted ...]
files.old_path: AppServer/google/appengine/ext/remote_api/remote_api_stub.py
files.new_contents: #!/usr/bin/env python
  #
  # Copyright 2007 Google Inc.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  #
  """The main entry point for the new development server."""
  
  
  import argparse
  import errno
  import getpass
  import itertools
  import logging
  import os
  import sys
  import tempfile
  import time
  
  from google.appengine.datastore import datastore_stub_util
  from google.appengine.tools import boolean_action
  from google.appengine.tools.devappserver2.admin import admin_server
  from google.appengine.tools.devappserver2 import api_server
  from google.appengine.tools.devappserver2 import application_configuration
  from google.appengine.tools.devappserver2 import dispatcher
  from google.appengine.tools.devappserver2 import login
  from google.appengine.tools.devappserver2 import runtime_config_pb2
  from google.appengine.tools.devappserver2 import shutdown
  from google.appengine.tools.devappserver2 import update_checker
  from google.appengine.tools.devappserver2 import wsgi_request_info
  
  from appscale.common import appscale_info
  
  # Initialize logging early -- otherwise some library packages may
  # pre-empt our log formatting.  NOTE: the level is provisional; it may
  # be changed in main() based on the --debug flag.
  logging.basicConfig(
      level=logging.INFO
  
  [... the rest is omitted ...]
files.new_path: AppServer/google/appengine/tools/devappserver2/devappserver2.py
files.old_contents: #!/usr/bin/env python
  #
  # Copyright 2007 Google Inc.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  #
  """The main entry point for the new development server."""
  
  
  import argparse
  import errno
  import getpass
  import itertools
  import logging
  import os
  import sys
  import tempfile
  import time
  
  from google.appengine.datastore import datastore_stub_util
  from google.appengine.tools import boolean_action
  from google.appengine.tools.devappserver2.admin import admin_server
  from google.appengine.tools.devappserver2 import api_server
  from google.appengine.tools.devappserver2 import application_configuration
  from google.appengine.tools.devappserver2 import dispatcher
  from google.appengine.tools.devappserver2 import login
  from google.appengine.tools.devappserver2 import runtime_config_pb2
  from google.appengine.tools.devappserver2 import shutdown
  from google.appengine.tools.devappserver2 import update_checker
  from google.appengine.tools.devappserver2 import wsgi_request_info
  
  from appscale.common import appscale_info
  
  # Initialize logging early -- otherwise some library packages may
  # pre-empt our log formatting.  NOTE: the level is provisional; it may
  # be changed in main() based on the --debug flag.
  logging.basicConfig(
      level=logging.INFO
  
  [... the rest is omitted ...]
files.old_path: AppServer/google/appengine/tools/devappserver2/devappserver2.py
files.new_contents: #!/usr/bin/env python
  #
  # Copyright 2007 Google Inc.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  #
  """Manage the lifecycle of modules and dispatch requests to them."""
  
  import collections
  import logging
  import os
  import threading
  import time
  import urlparse
  import wsgiref.headers
  
  from google.appengine.api import request_info
  from google.appengine.tools.devappserver2 import constants
  from google.appengine.tools.devappserver2 import instance
  from google.appengine.tools.devappserver2 import scheduled_executor
  from google.appengine.tools.devappserver2 import module
  from google.appengine.tools.devappserver2 import start_response_utils
  from google.appengine.tools.devappserver2 import thread_executor
  from google.appengine.tools.devappserver2 import wsgi_server
  
  _THREAD_POOL = thread_executor.ThreadExecutor()
  
  ResponseTuple = collections.namedtuple('ResponseTuple',
                                         ['status', 'headers', 'content'])
  
  
  class PortRegistry(object):
    def __init__(self):
      self._ports = {}
      self._ports_lock = threading.RLock()
  
    def add(self, port, _module, inst):
      with self._ports_lock:
        self._ports[port] = (_module, inst)
  
    def get(self, port):
      with self._ports_lock:
        return self._ports[port]
  
  
  
  
  [... the rest is omitted ...]
files.new_path: AppServer/google/appengine/tools/devappserver2/dispatcher.py
files.old_contents: #!/usr/bin/env python
  #
  # Copyright 2007 Google Inc.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  #
  """Manage the lifecycle of modules and dispatch requests to them."""
  
  import collections
  import logging
  import os
  import threading
  import time
  import urlparse
  import wsgiref.headers
  
  from google.appengine.api import request_info
  from google.appengine.tools.devappserver2 import constants
  from google.appengine.tools.devappserver2 import instance
  from google.appengine.tools.devappserver2 import scheduled_executor
  from google.appengine.tools.devappserver2 import module
  from google.appengine.tools.devappserver2 import start_response_utils
  from google.appengine.tools.devappserver2 import thread_executor
  from google.appengine.tools.devappserver2 import wsgi_server
  
  _THREAD_POOL = thread_executor.ThreadExecutor()
  
  ResponseTuple = collections.namedtuple('ResponseTuple',
                                         ['status', 'headers', 'content'])
  
  
  class PortRegistry(object):
    def __init__(self):
      self._ports = {}
      self._ports_lock = threading.RLock()
  
    def add(self, port, _module, inst):
      with self._ports_lock:
        self._ports[port] = (_module, inst)
  
    def get(self, port):
      with self._ports_lock:
        return self._ports[port]
  
  
  
  
  [... the rest is omitted ...]
files.old_path: AppServer/google/appengine/tools/devappserver2/dispatcher.py
files.new_contents: #!/usr/bin/env python
  #
  # Copyright 2007 Google Inc.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  #
  """Manage the lifecycle of runtime processes and dispatch requests to them."""
  
  
  import collections
  import cStringIO
  import functools
  import httplib
  import logging
  import math
  import os
  import os.path
  import random
  import re
  import string
  import struct
  import threading
  import time
  import urllib
  import urlparse
  import wsgiref.headers
  
  from google.appengine.api import api_base_pb
  from google.appengine.api import apiproxy_stub_map
  from google.appengine.api import appinfo
  from google.appengine.api import request_info
  from google.appengine.api.logservice import log_service_pb
  from google.appengine.tools.devappserver2 import application_configuration
  from google.appengine.tools.devappserver2 import blob_image
  from google.appengine.tools.devappserver2 import blob_upload
  from google.appengine.tools.devappserver2 import channel
  from google.appengine.tools.devappserver2 import constants
  
  from google.appengine.tools.devappserver2 import endpoints
  from google.appengine.tools.devappserver2 import errors
  from google.appengine.tools.devappserver2 import file_watcher
  from google.appengine.tools.devappserver2 import go_runtime
  from google.appengine
  
  [... the rest is omitted ...]
files.new_path: AppServer/google/appengine/tools/devappserver2/module.py
files.old_contents: #!/usr/bin/env python
  #
  # Copyright 2007 Google Inc.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  #
  """Manage the lifecycle of runtime processes and dispatch requests to them."""
  
  
  import collections
  import cStringIO
  import functools
  import httplib
  import logging
  import math
  import os
  import os.path
  import random
  import re
  import string
  import threading
  import time
  import urllib
  import urlparse
  import wsgiref.headers
  
  from google.appengine.api import api_base_pb
  from google.appengine.api import apiproxy_stub_map
  from google.appengine.api import appinfo
  from google.appengine.api import request_info
  from google.appengine.api.logservice import log_service_pb
  from google.appengine.tools.devappserver2 import application_configuration
  from google.appengine.tools.devappserver2 import blob_image
  from google.appengine.tools.devappserver2 import blob_upload
  from google.appengine.tools.devappserver2 import channel
  from google.appengine.tools.devappserver2 import constants
  
  from google.appengine.tools.devappserver2 import endpoints
  from google.appengine.tools.devappserver2 import errors
  from google.appengine.tools.devappserver2 import file_watcher
  from google.appengine.tools.devappserver2 import go_runtime
  from google.appengine.tools.dev
  
  [... the rest is omitted ...]
files.old_path: AppServer/google/appengine/tools/devappserver2/module.py
files.new_contents: #!/usr/bin/env python
  #
  # Copyright 2007 Google Inc.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  #
  """A Python devappserver2 runtime."""
  
  
  import base64
  import os
  import struct
  import sys
  import time
  import traceback
  
  import google
  
  from google.appengine.api import rdbms_mysqldb
  from google.appengine.ext.remote_api import remote_api_stub
  from google.appengine.tools.devappserver2 import request_rewriter
  from google.appengine.tools.devappserver2 import runtime_config_pb2
  from google.appengine.tools.devappserver2 import wsgi_server
  from google.appengine.tools.devappserver2.python import sandbox
  
  
  _STARTUP_FAILURE_TEMPLATE = """
  <!DOCTYPE html>
  <html>
  <head>
  <title>Startup Script Failure</title>
  </head>
  
  <body>
  <b>Debugger startup failed: {exception_message}</b>
  <details>
    <summary>Configuration</summary>
    <pre><code>{config}</code></pre>
  </details>
  <details>
    <summary>Traceback</summary>
    <pre><code>{traceback}</code></pre>
  </details>
  </body>
  </html>"""
  
  
  def setup_stubs(config, external_api_port=None):
    """Sets up API stubs using remote API."""
    if external_api_port is None:
  
  
  [... the rest is omitted ...]
files.new_path: AppServer/google/appengine/tools/devappserver2/python/runtime.py
files.old_contents: #!/usr/bin/env python
  #
  # Copyright 2007 Google Inc.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  #
  """A Python devappserver2 runtime."""
  
  
  import base64
  import os
  import sys
  import time
  import traceback
  
  import google
  
  from google.appengine.api import rdbms_mysqldb
  from google.appengine.ext.remote_api import remote_api_stub
  from google.appengine.tools.devappserver2 import request_rewriter
  from google.appengine.tools.devappserver2 import runtime_config_pb2
  from google.appengine.tools.devappserver2 import wsgi_server
  from google.appengine.tools.devappserver2.python import sandbox
  
  
  _STARTUP_FAILURE_TEMPLATE = """
  <!DOCTYPE html>
  <html>
  <head>
  <title>Startup Script Failure</title>
  </head>
  
  <body>
  <b>Debugger startup failed: {exception_message}</b>
  <details>
    <summary>Configuration</summary>
    <pre><code>{config}</code></pre>
  </details>
  <details>
    <summary>Traceback</summary>
    <pre><code>{traceback}</code></pre>
  </details>
  </body>
  </html>"""
  
  
  def setup_stubs(config):
    """Sets up API stubs using remote API."""
    remote_api_stub.ConfigureRemoteApi(config.app_id, '/', lambda
  
  [... the rest is omitted ...]
files.old_path: AppServer/google/appengine/tools/devappserver2/python/runtime.py