{"action":"created","comment":{"url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/comments/38053985","id":38053985,"diff_hunk":"@@ -0,0 +1,216 @@\n+# Copyright 2015 Google Inc. All Rights Reserved.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+#     http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+#\n+\"\"\"Utilities to configure the dispatcher, middleware and environment.\"\"\"\n+\n+import logging\n+import os\n+import threading\n+import UserDict\n+\n+from static_files import static_app_for_regex_and_files\n+\n+from google.appengine.api import appinfo\n+from google.appengine.api import appinfo_includes\n+from google.appengine.runtime import wsgi\n+\n+\n+def get_module_config_filename():\n+  \"\"\"Returns the path of the module configuration file (e.g. 'app.yaml').\n+\n+  Returns:\n+    The path of the module configuration file.\n+\n+  Raises:\n+    KeyError: The MODULE_YAML_PATH environment variable is not set.\n+  \"\"\"\n+  module_yaml_path = os.environ['MODULE_YAML_PATH']\n+  logging.info('Using module_yaml_path from env: %s', module_yaml_path)\n+  return module_yaml_path\n+\n+\n+def get_module_config(filename):\n+  \"\"\"Returns the parsed module config.\"\"\"\n+  with open(filename) as f:\n+    return appinfo_includes.Parse(f)\n+\n+\n+def app_for_script(script):\n+  \"\"\"Returns the WSGI app specified in the input string, or None on failure.\"\"\"\n+  try:\n+    app, unused_filename, err = wsgi.LoadObject(script)\n+    if err:\n+      raise err\n+  except ImportError as e:\n+    # Despite nominally returning an error object, LoadObject will sometimes\n+    # just result in an exception. By raising the err object if it exists, we\n+    # catch either.\n+    logging.exception('Failed to import %s', script)\n+    return None\n+  else:\n+    return app_wrapped_in_user_middleware(app)\n+\n+\n+def app_wrapped_in_user_middleware(app):\n+  \"\"\"Returns the input WSGI app, wrapped in appengine_config middleware.\"\"\"\n+  add_middleware = get_add_middleware_from_appengine_config()\n+  if add_middleware:\n+    return add_middleware(app)\n+  else:\n+    return app\n+\n+\n+def get_add_middleware_from_appengine_config():\n+  \"\"\"Tries to import appengine_config and return middleware; fails silently.\n+\n+  `env_config` is optionally part of GAE-compatible user code.\n+  If the user chooses to define the `webapp_add_wsgi_middleware` function\n+  there, then we will use it to wrap app scripts. This is used for e.g.\n+  appstats. Many user apps do not have or need env_config, so failure\n+  to import it or failure to find `webapp_add_wsgi_middleware` is not an\n+  error.\n+\n+  Returns:\n+    The appengine_config.webapp_add_wsgi_middleware function or None.\n+  \"\"\"\n+  try:\n+    import appengine_config  # pylint: disable=g-import-not-at-top\n+    return getattr(appengine_config, 'webapp_add_wsgi_middleware', None)\n+  except ImportError:\n+    return None\n+\n+\n+def static_app_for_handler(handler):\n+  \"\"\"Returns a WSGI app that serves static files as directed by the handler.\n+\n+  Args:\n+    handler: An individual handler from appinfo_external.handlers\n+      (appinfo.URLMap)\n+\n+  Returns:\n+    A static file-serving WSGI app closed over the handler information.\n+  \"\"\"\n+  url_re = handler.url  # handler.url is a regex, despite the name.\n+  files = handler.static_files\n+  upload = handler.upload\n+  if not files:\n+    if handler.static_dir:\n+      # If static_files is not set, convert static_dir to static_files and also\n+      # modify the url regex accordingly. See the appinfo.URLMap docstring for\n+      # more information.\n+      url_re = static_dir_url(handler)\n+      files = '{dir}{backref}'.format(dir=handler.static_dir, backref=r'/\\1')","path":"multicore_runtime/wsgi_config.py","position":113,"original_position":113,"commit_id":"346a86d4421d5dd623e7d81f64edaa222b5fa4f0","original_commit_id":"205cc96be414f285d80c8117e60bd656ac079633","user":{"login":"andrewsg","id":686551,"avatar_url":"https://avatars.githubusercontent.com/u/686551?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewsg","html_url":"https://github.com/andrewsg","followers_url":"https://api.github.com/users/andrewsg/followers","following_url":"https://api.github.com/users/andrewsg/following{/other_user}","gists_url":"https://api.github.com/users/andrewsg/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewsg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewsg/subscriptions","organizations_url":"https://api.github.com/users/andrewsg/orgs","repos_url":"https://api.github.com/users/andrewsg/repos","events_url":"https://api.github.com/users/andrewsg/events{/privacy}","received_events_url":"https://api.github.com/users/andrewsg/received_events","type":"User","site_admin":false},"body":"Done.","created_at":"2015-08-27T01:16:41Z","updated_at":"2015-08-27T01:16:41Z","html_url":"https://github.com/andrewsg/appengine-python-vm-runtime/pull/1#discussion_r38053985","pull_request_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/comments/38053985"},"html":{"href":"https://github.com/andrewsg/appengine-python-vm-runtime/pull/1#discussion_r38053985"},"pull_request":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/1","id":42734664,"html_url":"https://github.com/andrewsg/appengine-python-vm-runtime/pull/1","diff_url":"https://github.com/andrewsg/appengine-python-vm-runtime/pull/1.diff","patch_url":"https://github.com/andrewsg/appengine-python-vm-runtime/pull/1.patch","issue_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues/1","number":1,"state":"open","locked":false,"title":"Re-submit files for readability review","user":{"login":"andrewsg","id":686551,"avatar_url":"https://avatars.githubusercontent.com/u/686551?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewsg","html_url":"https://github.com/andrewsg","followers_url":"https://api.github.com/users/andrewsg/followers","following_url":"https://api.github.com/users/andrewsg/following{/other_user}","gists_url":"https://api.github.com/users/andrewsg/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewsg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewsg/subscriptions","organizations_url":"https://api.github.com/users/andrewsg/orgs","repos_url":"https://api.github.com/users/andrewsg/repos","events_url":"https://api.github.com/users/andrewsg/events{/privacy}","received_events_url":"https://api.github.com/users/andrewsg/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-18T18:52:55Z","updated_at":"2015-08-27T01:16:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d9df93b15ce2523ea186573eb27e209a1fb642e9","assignee":{"login":"filbranden","id":106037,"avatar_url":"https://avatars.githubusercontent.com/u/106037?v=3","gravatar_id":"","url":"https://api.github.com/users/filbranden","html_url":"https://github.com/filbranden","followers_url":"https://api.github.com/users/filbranden/followers","following_url":"https://api.github.com/users/filbranden/following{/other_user}","gists_url":"https://api.github.com/users/filbranden/gists{/gist_id}","starred_url":"https://api.github.com/users/filbranden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/filbranden/subscriptions","organizations_url":"https://api.github.com/users/filbranden/orgs","repos_url":"https://api.github.com/users/filbranden/repos","events_url":"https://api.github.com/users/filbranden/events{/privacy}","received_events_url":"https://api.github.com/users/filbranden/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/1/commits","review_comments_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/1/comments","review_comment_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues/1/comments","statuses_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/statuses/346a86d4421d5dd623e7d81f64edaa222b5fa4f0","head":{"label":"andrewsg:readability","ref":"readability","sha":"346a86d4421d5dd623e7d81f64edaa222b5fa4f0","user":{"login":"andrewsg","id":686551,"avatar_url":"https://avatars.githubusercontent.com/u/686551?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewsg","html_url":"https://github.com/andrewsg","followers_url":"https://api.github.com/users/andrewsg/followers","following_url":"https://api.github.com/users/andrewsg/following{/other_user}","gists_url":"https://api.github.com/users/andrewsg/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewsg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewsg/subscriptions","organizations_url":"https://api.github.com/users/andrewsg/orgs","repos_url":"https://api.github.com/users/andrewsg/repos","events_url":"https://api.github.com/users/andrewsg/events{/privacy}","received_events_url":"https://api.github.com/users/andrewsg/received_events","type":"User","site_admin":false},"repo":{"id":37627647,"name":"appengine-python-vm-runtime","full_name":"andrewsg/appengine-python-vm-runtime","owner":{"login":"andrewsg","id":686551,"avatar_url":"https://avatars.githubusercontent.com/u/686551?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewsg","html_url":"https://github.com/andrewsg","followers_url":"https://api.github.com/users/andrewsg/followers","following_url":"https://api.github.com/users/andrewsg/following{/other_user}","gists_url":"https://api.github.com/users/andrewsg/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewsg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewsg/subscriptions","organizations_url":"https://api.github.com/users/andrewsg/orgs","repos_url":"https://api.github.com/users/andrewsg/repos","events_url":"https://api.github.com/users/andrewsg/events{/privacy}","received_events_url":"https://api.github.com/users/andrewsg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andrewsg/appengine-python-vm-runtime","description":"Google Managed VMs Python Runtime","fork":true,"url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime","forks_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/forks","keys_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/teams","hooks_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/hooks","issue_events_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues/events{/number}","events_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/events","assignees_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/assignees{/user}","branches_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/branches{/branch}","tags_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/tags","blobs_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/refs{/sha}","trees_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/statuses/{sha}","languages_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/languages","stargazers_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/stargazers","contributors_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/contributors","subscribers_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/subscribers","subscription_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/subscription","commits_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/commits{/sha}","git_commits_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/commits{/sha}","comments_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/comments{/number}","issue_comment_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues/comments{/number}","contents_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/contents/{+path}","compare_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/merges","archive_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/downloads","issues_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues{/number}","pulls_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls{/number}","milestones_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/milestones{/number}","notifications_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/labels{/name}","releases_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/releases{/id}","created_at":"2015-06-18T00:02:48Z","updated_at":"2015-06-18T00:03:17Z","pushed_at":"2015-08-21T23:14:18Z","git_url":"git://github.com/andrewsg/appengine-python-vm-runtime.git","ssh_url":"git@github.com:andrewsg/appengine-python-vm-runtime.git","clone_url":"https://github.com/andrewsg/appengine-python-vm-runtime.git","svn_url":"https://github.com/andrewsg/appengine-python-vm-runtime","homepage":"","size":26009,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"andrewsg:readability-base","ref":"readability-base","sha":"93234db0efb2f3465ade3198575adffb0bc1afef","user":{"login":"andrewsg","id":686551,"avatar_url":"https://avatars.githubusercontent.com/u/686551?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewsg","html_url":"https://github.com/andrewsg","followers_url":"https://api.github.com/users/andrewsg/followers","following_url":"https://api.github.com/users/andrewsg/following{/other_user}","gists_url":"https://api.github.com/users/andrewsg/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewsg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewsg/subscriptions","organizations_url":"https://api.github.com/users/andrewsg/orgs","repos_url":"https://api.github.com/users/andrewsg/repos","events_url":"https://api.github.com/users/andrewsg/events{/privacy}","received_events_url":"https://api.github.com/users/andrewsg/received_events","type":"User","site_admin":false},"repo":{"id":37627647,"name":"appengine-python-vm-runtime","full_name":"andrewsg/appengine-python-vm-runtime","owner":{"login":"andrewsg","id":686551,"avatar_url":"https://avatars.githubusercontent.com/u/686551?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewsg","html_url":"https://github.com/andrewsg","followers_url":"https://api.github.com/users/andrewsg/followers","following_url":"https://api.github.com/users/andrewsg/following{/other_user}","gists_url":"https://api.github.com/users/andrewsg/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewsg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewsg/subscriptions","organizations_url":"https://api.github.com/users/andrewsg/orgs","repos_url":"https://api.github.com/users/andrewsg/repos","events_url":"https://api.github.com/users/andrewsg/events{/privacy}","received_events_url":"https://api.github.com/users/andrewsg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andrewsg/appengine-python-vm-runtime","description":"Google Managed VMs Python Runtime","fork":true,"url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime","forks_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/forks","keys_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/teams","hooks_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/hooks","issue_events_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues/events{/number}","events_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/events","assignees_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/assignees{/user}","branches_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/branches{/branch}","tags_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/tags","blobs_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/refs{/sha}","trees_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/statuses/{sha}","languages_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/languages","stargazers_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/stargazers","contributors_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/contributors","subscribers_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/subscribers","subscription_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/subscription","commits_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/commits{/sha}","git_commits_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/git/commits{/sha}","comments_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/comments{/number}","issue_comment_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues/comments{/number}","contents_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/contents/{+path}","compare_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/merges","archive_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/downloads","issues_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues{/number}","pulls_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls{/number}","milestones_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/milestones{/number}","notifications_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/labels{/name}","releases_url":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/releases{/id}","created_at":"2015-06-18T00:02:48Z","updated_at":"2015-06-18T00:03:17Z","pushed_at":"2015-08-21T23:14:18Z","git_url":"git://github.com/andrewsg/appengine-python-vm-runtime.git","ssh_url":"git@github.com:andrewsg/appengine-python-vm-runtime.git","clone_url":"https://github.com/andrewsg/appengine-python-vm-runtime.git","svn_url":"https://github.com/andrewsg/appengine-python-vm-runtime","homepage":"","size":26009,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/1"},"html":{"href":"https://github.com/andrewsg/appengine-python-vm-runtime/pull/1"},"issue":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues/1"},"comments":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/andrewsg/appengine-python-vm-runtime/statuses/346a86d4421d5dd623e7d81f64edaa222b5fa4f0"}}}}