-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b4c512
commit 3c9cf8c
Showing
7 changed files
with
100 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
""" configuration variables """ | ||
|
||
import configparser | ||
import os | ||
import uuid | ||
|
||
def parse_bool(OPTION): | ||
if OPTION == '0': | ||
OPTION = False | ||
else: | ||
OPTION = True | ||
return OPTION | ||
|
||
|
||
_conf = configparser.ConfigParser() | ||
_conf_file_paths = [] | ||
|
||
if 'HOME' in os.environ: | ||
_conf_file_path = os.path.join(os.environ['HOME'], ".mavcesium.ini") | ||
_conf_file_paths.append(_conf_file_path) | ||
if 'LOCALAPPDATA' in os.environ: | ||
_conf_file_path = os.path.join(os.environ['LOCALAPPDATA'], "MAVProxy", "mavcesium.ini") | ||
_conf_file_paths.append(_conf_file_path) | ||
|
||
try: # try to use pkg_resources to allow for zipped python eggs | ||
import pkg_resources | ||
_cur_dir = pkg_resources.resource_filename('MAVProxy.modules.mavproxy_cesium','app') | ||
except: # otherwise fall back to the standard file system | ||
_cur_dir = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
_conf_file_paths.append(os.path.join(_cur_dir, 'mavcesium_default.ini')) | ||
|
||
for _conf_file_path in _conf_file_paths: | ||
if os.path.exists(_conf_file_path): | ||
try: | ||
# load the config | ||
_conf.read_file(open(_conf_file_path)) | ||
|
||
SERVER_INTERFACE = _conf.get('general', 'server_interface') | ||
SERVER_PORT = _conf.get('general', 'server_port') | ||
WEBSOCKET = "ws://"+SERVER_INTERFACE+":"+SERVER_PORT+"/ws" | ||
|
||
BING_API_KEY = _conf.get('api_keys', 'bing') | ||
|
||
FLASK_SECRET_KEY = _conf.get('general', 'flask_secret_key') | ||
if FLASK_SECRET_KEY == '': | ||
FLASK_SECRET_KEY = str(uuid.uuid4()) | ||
|
||
APP_DEBUG = parse_bool(_conf.get('debug', 'app_debug')) | ||
MODULE_DEBUG = parse_bool(_conf.get('debug', 'module_debug')) | ||
|
||
|
||
if MODULE_DEBUG: | ||
print ('Using config file at {}'.format( _conf_file_path )) | ||
break # use first working config | ||
|
||
except Exception as e: | ||
print ('Failed to use config file at {} : {}'.format( _conf_file_path, e )) | ||
|
||
|
||
|
||
# TODO: check for pass / fail and action | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[general] | ||
# web site url = eg. 'http://' + domain_name | ||
server_interface = 0.0.0.0 | ||
server_port = 5000 | ||
flask_secret_key = '' | ||
|
||
[api_keys] | ||
bing = Auw42O7s-dxnXl0f0HdmOoIAD3bvbPjFOVKDN9nNKrf1uroCCBxetdPowaQF4XaG | ||
|
||
[debug] | ||
app_debug = 1 | ||
module_debug = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
Flask>=0.11.1 | ||
autobahn[twisted] | ||
configparser |