This repository has been archived by the owner on Aug 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathappengine_config.py
46 lines (36 loc) · 1.63 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
"""
`appengine_config.py` gets loaded every time a new instance is started.
Use this file to configure app engine modules as defined here:
https://developers.google.com/appengine/docs/python/tools/appengineconfig
"""
def add_vendor_packages(vendor_folder):
"""
Adds our vendor packages folder to sys.path so that third-party
packages can be imported.
"""
import site
import os.path
import sys
# Use site.addsitedir() because it appropriately reads .pth
# files for namespaced packages. Unfortunately, there's not an
# option to choose where addsitedir() puts its paths in sys.path
# so we have to do a little bit of magic to make it play along.
# We're going to grab the current sys.path and split it up into
# the first entry and then the rest. Essentially turning
# ['.', '/site-packages/x', 'site-packages/y']
# into
# ['.'] and ['/site-packages/x', 'site-packages/y']
# The reason for this is we want '.' to remain at the top of the
# list but we want our vendor files to override everything else.
sys.path, remainder = sys.path[:1], sys.path[1:]
# Now we call addsitedir which will append our vendor directories
# to sys.path (which was truncated by the last step.)
site.addsitedir(os.path.join(os.path.dirname(__file__), vendor_folder))
# Finally, we'll add the paths we removed back.
sys.path.extend(remainder)
# Change 'lib' to whichever directory you use for your vendored packages.
add_vendor_packages('lib')
from googleapiclient import discovery
from oauth2client import client
discovery.logger.setLevel('WARNING')
client.logger.setLevel('WARNING')