|
import os |
|
|
|
from internals.data.task import Task |
|
|
|
env = "gamma" |
|
nsfw_threshold = 0.0 |
|
nsfw_access = False |
|
access_token = "" |
|
root_dir = "" |
|
|
|
|
|
def set_root_dir(main_file: str): |
|
global root_dir |
|
root_dir = os.path.dirname(os.path.abspath(main_file)) |
|
|
|
|
|
def set_configs_from_task(task: Task): |
|
global env, nsfw_threshold, nsfw_access, access_token |
|
name = task.get_queue_name() |
|
if name.startswith("prod"): |
|
env = "prod" |
|
else: |
|
env = "gamma" |
|
nsfw_threshold = task.get_nsfw_threshold() |
|
nsfw_access = task.can_access_nsfw() |
|
access_token = task.get_access_token() |
|
|
|
|
|
def get_root_dir(): |
|
global root_dir |
|
return root_dir |
|
|
|
|
|
def get_environment(): |
|
global env |
|
return env |
|
|
|
|
|
def get_nsfw_threshold(): |
|
global nsfw_threshold |
|
return nsfw_threshold |
|
|
|
|
|
def get_nsfw_access(): |
|
global nsfw_access |
|
return nsfw_access |
|
|
|
|
|
def api_headers(): |
|
return { |
|
"Access-Token": access_token, |
|
} |
|
|
|
|
|
def api_endpoint(): |
|
if env == "prod": |
|
return "https://prod.pratilipicomics.com" |
|
else: |
|
return "https://gamma.pratilipicomics.com" |
|
|
|
|
|
def comic_url(): |
|
if env == "prod": |
|
return "http://internal-k8s-prod-internal-bb9c57a6bb-1524739074.ap-south-1.elb.amazonaws.com:80" |
|
else: |
|
return "http://internal-k8s-gamma-internal-ea8e32da94-1997933257.ap-south-1.elb.amazonaws.com:80" |
|
|