forked from luci/luci-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
appengine_config.py
46 lines (36 loc) · 1.42 KB
/
appengine_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Copyright 2013 The Swarming Authors. All rights reserved.
# Use of this source code is governed by the Apache v2.0 license that can be
# found in the LICENSE file.
"""Configures includes (components.auth).
https://developers.google.com/appengine/docs/python/tools/appengineconfig
"""
import os
components_auth_UI_APP_NAME = 'Isolate Server'
def hack_windows():
"""Adds support for symlink-as-file on Windows.
Manually resolves symlinks in path for directory and add them to sys.path.
"""
import sys
# Disable AppEngine's sandbox.
from google.appengine.tools.devappserver2.python import stubs
stubs.FakeFile.is_file_accessible = staticmethod(lambda *_: True)
sys.meta_path = []
for i in os.listdir('.'):
if '.' in i or not os.path.isfile(i):
continue
# Found a file instead of a symlink to a directory. Adjust sys.path
# accordingly to where the symlink points.
with open(i) as f:
link = f.read()
if '\n' not in link:
# This is not exactly right but close enough.
sys.path.insert(
0, os.path.dirname(os.path.normpath(os.path.abspath(link))))
sys.path.insert(
0,
os.path.normpath(os.path.abspath(
os.path.join('..', 'components', 'components', 'third_party'))))
if os.__file__[0] != '/':
# Hack for smoke tests to pass on Windows. dev_appserver hacks the python
# sys.platform value by setting it to 'linux3' on all platforms.
hack_windows()