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

Updated config.py more platform independent (Win32) #53

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ error.log
MANIFEST.in
requirements.txt
setup.py
*.pyc
.idea/.gitignore
.idea/codestream.xml
.idea/dataSources.local.xml
.idea/dataSources.xml
.idea/deployment.xml
.idea/*.iml
.idea/misc.xml
.idea/modules.xml
.idea/sshConfigs.xml
Expand All @@ -17,6 +18,7 @@ setup.py
.idea/workspace.xml
.idea/dataSources/d2683b90-b3df-414a-a758-2bb47305f676.xml
.idea/inspectionProfiles/Project_Default.xml
.idea/inspectionProfiles/profiles_settings.xml
.idea/sonarlint/issuestore/index.pb
.idea/sonarlint/issuestore/1/a/1a1b9769344cb239f2e540e1e6ee1efa2d3034ea
.idea/sonarlint/issuestore/3/d/3d01a26b2d15866ee22d2d43f4cbbf769ab0d414
Expand Down
65 changes: 40 additions & 25 deletions FreeTAKServer-UI/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,71 @@
Copyright (c) 2019 - present AppSeed.us
"""

import os
from os import environ
from pathlib import Path
import yaml

PERSISTENCE_PATH = r'/opt/fts'
YAML_PATH = f"{PERSISTENCE_PATH}/FTSConfig.yaml"


class Config(object):
basedir = os.path.abspath(os.path.dirname(__file__))
basedir = Path(__file__).parent.absolute()
purelib_path = basedir.parent

with open(YAML_PATH, "r") as stream:
config_yaml = yaml.safe_load(stream)
if config_yaml is None:
config_yaml = {}

SECRET_KEY = 'key'

# This will connect to the FTS db
SQLALCHEMY_DATABASE_URI = environ.get('FTS_UI_SQLALCHEMY_DATABASE_URI', 'sqlite:///' + '/opt/FTSServer-UI.db')

# experimental SSL support in the UI
SQLALCHEMY_DATABASE_URI = environ.get('FTS_UI_SQLALCHEMY_DATABASE_URI',
config_yaml.get('SQLALCHEMY_DATABASE_URI',
'sqlite:///' + '/opt/fts/FTSServer-UI.db'))

# certificates path
# certpath = "/usr/local/lib/python3.8/dist-packages/FreeTAKServer/certs/"
# cert_path = Path("/opt/fts.venv/lib/python3.11/site-packages/FreeTAKServer/certs/")
# or platform independently
# cert_path = purelib_path / 'FreeTAKServer' / 'certs'

# crt file path
# crtfilepath = f"{certpath}pubserver.pem"
# crtfilepath = str(cert_path / "pubserver.pem")

# key file path
# keyfilepath = f"{certpath}pubserver.key.unencrypted"
# keyfilepath = str(cert_path / "pubserver.key.unencrypted")

# this IP will be used to connect with the FTS API
IP = environ.get('FTS_IP', '127.0.0.1')
IP = environ.get('FTS_IP', config_yaml.get('FTS_IP', '127.0.0.1'))

# Port the UI uses to communicate with the API
PORT = environ.get('FTS_API_PORT', '19023')
PORT = environ.get('FTS_API_PORT', config_yaml.get('FTS_API_PORT', '19023'))

# Protocol the UI uses to communicate with the API
PROTOCOL = environ.get('FTS_API_PROTO', 'http')
PROTOCOL = environ.get('FTS_API_PROTO', config_yaml.get('FTS_API_PROTO', 'http'))

# the public IP your server is exposing
APPIP = environ.get('FTS_UI_EXPOSED_IP', '127.0.0.1')
APPIP = environ.get('FTS_UI_EXPOSED_IP', config_yaml.get('FTS_UI_EXPOSED_IP', '127.0.0.1'))

# webmap IP
WEBMAPIP = environ.get('FTS_MAP_EXPOSED_IP', '127.0.0.1')
WEBMAPIP = environ.get('FTS_MAP_EXPOSED_IP', config_yaml.get('FTS_MAP_EXPOSED_IP', '127.0.0.1'))

# webmap port
WEBMAPPORT = int(environ.get('FTS_MAP_PORT', 8000))
WEBMAPPORT = int(environ.get('FTS_MAP_PORT', config_yaml.get('FTS_MAP_PORT', 8000)))

# webmap protocol
WEBMAPPROTOCOL = environ.get('FTS_MAP_PROTO', 'http')
WEBMAPPROTOCOL = environ.get('FTS_MAP_PROTO', config_yaml.get('FTS_MAP_PROTO', 'http'))

# this port will be used to listen
APPPort = int(environ.get('FTS_UI_PORT', 5000))
APPPort = int(environ.get('FTS_UI_PORT', config_yaml.get('FTS_UI_PORT', 5000)))

# the webSocket key used by the UI to communicate with FTS.
WEBSOCKETKEY = environ.get('FTS_UI_WSKEY', 'YourWebsocketKey')
WEBSOCKETKEY = environ.get('FTS_UI_WSKEY', config_yaml.get('FTS_UI_WSKEY', 'YourWebsocketKey'))

# the API key used by the UI to comunicate with FTS. generate a new system user and then set it
APIKEY = environ.get('FTS_API_KEY', 'Bearer token')
# the API key used by the UI to communicate with FTS.
# generate a new system user and then set it.
APIKEY = environ.get('FTS_API_KEY', config_yaml.get('FTS_API_KEY', 'Bearer token'))

# For 'in memory' database, please use:
# SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'
Expand All @@ -78,13 +91,15 @@ class ProductionConfig(Config):
REMEMBER_COOKIE_HTTPONLY = True
REMEMBER_COOKIE_DURATION = 3600

cy = Config.config_yaml

# PostgreSQL database
SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}:{}/{}'.format(
environ.get('APPSEED_DATABASE_USER', 'appseed'),
environ.get('APPSEED_DATABASE_PASSWORD', 'appseed'),
environ.get('APPSEED_DATABASE_HOST', 'db'),
environ.get('APPSEED_DATABASE_PORT', 5432),
environ.get('APPSEED_DATABASE_NAME', 'appseed')
environ.get('APPSEED_DATABASE_USER', cy.get('APPSEED_DATABASE_USER', 'appseed')),
environ.get('APPSEED_DATABASE_PASSWORD', cy.get('APPSEED_DATABASE_PASSWORD', 'appseed')),
environ.get('APPSEED_DATABASE_HOST', cy.get('APPSEED_DATABASE_HOST', 'db')),
environ.get('APPSEED_DATABASE_PORT', cy.get('APPSEED_DATABASE_PORT', 5432)),
environ.get('APPSEED_DATABASE_NAME', cy.get('APPSEED_DATABASE_NAME', 'appseed'))
)


Expand All @@ -95,4 +110,4 @@ class DebugConfig(Config):
config_dict = {
'Production': ProductionConfig,
'Debug': DebugConfig
}
}