-
Notifications
You must be signed in to change notification settings - Fork 2
/
paths.py
48 lines (37 loc) · 1.34 KB
/
paths.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
47
48
"""
Should this be moved to constants?
"""
import os
from os.path import dirname, abspath, relpath, join
import functools
import shutil
import bottle
from bottle import jinja2_view
from constants import C
HOME = os.getenv('HOME')
if HOME is None:
HOME = ''
ROOT_DIR = dirname(abspath(__file__))
STATIC_DIR = join(ROOT_DIR, 'static')
ETC_DIR = join(ROOT_DIR, 'etc')
TEMPLATE_DIR = join(ROOT_DIR, 'templates')
TEST_DIR = join(ROOT_DIR, 'tests')
TEST_DATA_DIR = join(ROOT_DIR, 'tests', 'data')
SCHEMA_FILE = join(ROOT_DIR, 'etc', 'schema.sql')
SCHEMA_TEMPLATE = join(ROOT_DIR, 'etc', 'schema_{schema}.sql')
SCHEMA0_FILE = SCHEMA_TEMPLATE.format(schema=0)
SCHEMA1_FILE = SCHEMA_TEMPLATE.format(schema=1)
AWS_LAMBDA_LINUX_STATIC_FFMPEG = join(ETC_DIR, 'ffmpeg-6.1-amd64-static')
# used by test program:
BOTTLE_APP_PATH = join(ROOT_DIR, 'bottle_app.py')
# Add the relative template path (since jinja2 doesn't like absolute paths)
bottle.TEMPLATE_PATH.append(relpath(TEMPLATE_DIR))
# Create the @view decorator to add template to the function output
view = functools.partial(jinja2_view)
def running_in_aws_lambda():
return C.AWS_LAMBDA_ENVIRON in os.environ
def ffmpeg_path():
if running_in_aws_lambda():
return AWS_LAMBDA_LINUX_STATIC_FFMPEG
else:
return shutil.which('ffmpeg')