forked from andrewxhill/gfw-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
40 lines (32 loc) · 1.37 KB
/
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
import os
import ee
import json
from oauth2client.appengine import AppAssertionCredentials
def _load_asset_ids():
"""Return private EE asset ids as dictionary."""
path = os.path.join(os.path.abspath(
os.path.dirname(__file__)), 'ee_asset_ids.json')
try:
return json.loads(open(path, "r").read())
except:
return {}
# The URL of the Earth Engine API.
EE_URL = 'https://earthengine.googleapis.com'
# The service account email address authorized by your Google contact.
EE_ACCOUNT = '[email protected]'
# The private key associated with your service account in Privacy Enhanced
# Email format (.pem suffix). To convert a private key from the RSA format
# (.p12 suffix) to .pem, run the openssl command like this:
# openssl pkcs12 -in downloaded-privatekey.p12 -nodes -nocerts > privatekey.pem
EE_PRIVATE_KEY_FILE = 'privatekey.pem'
# DEBUG_MODE will be True if running in a local development environment.
DEBUG_MODE = ('SERVER_SOFTWARE' in os.environ and
os.environ['SERVER_SOFTWARE'].startswith('Dev'))
# Set up the appropriate credentials depending on where we're running.
if DEBUG_MODE:
EE_CREDENTIALS = ee.ServiceAccountCredentials(
EE_ACCOUNT, EE_PRIVATE_KEY_FILE)
else:
EE_CREDENTIALS = AppAssertionCredentials(ee.OAUTH2_SCOPE)
assets = _load_asset_ids()