Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add requirements #38

Merged
merged 6 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions terrabutler/requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
def check_requirements():
"""
Check requirements before running the application.
"""
from terrabutler.settings import validate_settings
from os import getenv, path
from colorama import Fore

if getenv("TERRABUTLER_ENABLE") != "true":
print(Fore.YELLOW + "Terrabutler is not currently enabled on this"
" folder. Please set 'TERRABUTLER_ENABLE' in your environment"
" to true to enable it.")
exit(1)
root = getenv("TERRABUTLER_ROOT")
if root is None or not path.exists(root):
print(Fore.RED + "Terrabutler can't determine the root folder of"
" your project or it doesn't exist.\nPlease set"
" 'TERRABUTLER_ROOT' in your environment pointing"
" to the root folder of your project.")
exit(1)
if not path.exists(root + "configs/settings.yml"):
print(Fore.RED + "Terrabutler can't find you settings file\nPlease"
" create a 'settings.yml' file inside the 'configs' folder.")
exit(1)
validate_settings()
4 changes: 2 additions & 2 deletions terrabutler/settings.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from colorama import Fore
from os import path
from os import getenv, path
from schema import Schema, SchemaError
import yaml

PATH = path.realpath("configs/settings.yml")
PATH = path.realpath(getenv("TERRABUTLER_ROOT") + "configs/settings.yml")
SCHEMA = Schema({
"general": {
"organization": str,
Expand Down