mirror of https://github.com/DJ2LS/FreeDATA.git
starting flask inline
parent
33e2d63de1
commit
b941eda41a
|
@ -113,6 +113,7 @@ jobs:
|
||||||
path: .
|
path: .
|
||||||
# exclusions: '*.git* /*node_modules/* .editorconfig'
|
# exclusions: '*.git* /*node_modules/* .editorconfig'
|
||||||
|
|
||||||
|
|
||||||
- name: Release Modem
|
- name: Release Modem
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
|
|
|
@ -101,13 +101,14 @@ for file in files:
|
||||||
#log.info("[C2 ] Libcodec2 loaded", path=file)
|
#log.info("[C2 ] Libcodec2 loaded", path=file)
|
||||||
break
|
break
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
log.info("[C2 ] Error: Libcodec2 found but not loaded", path=file, e=err)
|
pass
|
||||||
|
#log.info("[C2 ] Error: Libcodec2 found but not loaded", path=file, e=err)
|
||||||
|
|
||||||
# Quit module if codec2 cant be loaded
|
# Quit module if codec2 cant be loaded
|
||||||
if api is None or "api" not in locals():
|
if api is None or "api" not in locals():
|
||||||
log.critical("[C2 ] Error: Libcodec2 not loaded - Exiting")
|
log.critical("[C2 ] Error: Libcodec2 not loaded - Exiting")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
log.info("[C2 ] Libcodec2 loaded...")
|
||||||
# ctypes function init
|
# ctypes function init
|
||||||
|
|
||||||
# api.freedv_set_tuning_range.restype = ctypes.c_int
|
# api.freedv_set_tuning_range.restype = ctypes.c_int
|
||||||
|
|
|
@ -11,22 +11,18 @@ import state_manager
|
||||||
import ujson as json
|
import ujson as json
|
||||||
import websocket_manager as wsm
|
import websocket_manager as wsm
|
||||||
import api_validations as validations
|
import api_validations as validations
|
||||||
import command_ping
|
|
||||||
import command_cq
|
import command_cq
|
||||||
import command_ping
|
import command_ping
|
||||||
import command_feq
|
import command_feq
|
||||||
import command_test
|
import command_test
|
||||||
import command_arq_raw
|
import command_arq_raw
|
||||||
import event_manager
|
import event_manager
|
||||||
import radio_manager
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
CORS(app)
|
CORS(app)
|
||||||
CORS(app, resources={r"/*": {"origins": "*"}})
|
CORS(app, resources={r"/*": {"origins": "*"}})
|
||||||
sock = Sock(app)
|
sock = Sock(app)
|
||||||
app.config['SOCK_SERVER_OPTIONS'] = {'ping_interval': 10}
|
MODEM_VERSION = "0.12.0-alpha"
|
||||||
# define global MODEM_VERSION
|
|
||||||
app.MODEM_VERSION = "0.12.0-alpha"
|
|
||||||
|
|
||||||
# set config file to use
|
# set config file to use
|
||||||
def set_config():
|
def set_config():
|
||||||
|
@ -41,26 +37,10 @@ def set_config():
|
||||||
print(f"Config file '{config_file}' not found. Exiting.")
|
print(f"Config file '{config_file}' not found. Exiting.")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
app.config_manager = CONFIG(config_file)
|
return config_file
|
||||||
|
|
||||||
set_config()
|
|
||||||
|
|
||||||
# start modem
|
|
||||||
app.state_queue = queue.Queue() # queue which holds latest states
|
|
||||||
app.modem_events = queue.Queue() # queue which holds latest events
|
|
||||||
app.modem_fft = queue.Queue() # queue which holds latest fft data
|
|
||||||
app.modem_service = queue.Queue() # start / stop modem service
|
|
||||||
app.event_manager = event_manager.EventManager([app.modem_events]) # TODO remove the app.modem_event custom queue
|
|
||||||
|
|
||||||
# init state manager
|
|
||||||
app.state_manager = state_manager.StateManager(app.state_queue)
|
|
||||||
|
|
||||||
# start service manager
|
|
||||||
app.service_manager = service_manager.SM(app)
|
|
||||||
|
|
||||||
|
|
||||||
# start modem service
|
|
||||||
app.modem_service.put("start")
|
|
||||||
|
|
||||||
# returns a standard API response
|
# returns a standard API response
|
||||||
def api_response(data, status = 200):
|
def api_response(data, status = 200):
|
||||||
|
@ -96,7 +76,7 @@ def index():
|
||||||
return api_response({'name': 'FreeDATA API',
|
return api_response({'name': 'FreeDATA API',
|
||||||
'description': '',
|
'description': '',
|
||||||
'api_version': 1,
|
'api_version': 1,
|
||||||
'modem_version': app.MODEM_VERSION,
|
'modem_version': MODEM_VERSION,
|
||||||
'license': 'GPL3.0',
|
'license': 'GPL3.0',
|
||||||
'documentation': 'https://wiki.freedata.app',
|
'documentation': 'https://wiki.freedata.app',
|
||||||
})
|
})
|
||||||
|
@ -279,7 +259,28 @@ def sock_fft(sock):
|
||||||
def sock_states(sock):
|
def sock_states(sock):
|
||||||
wsm.handle_connection(sock, wsm.states_client_list, app.state_queue)
|
wsm.handle_connection(sock, wsm.states_client_list, app.state_queue)
|
||||||
|
|
||||||
wsm.startThreads(app)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
app.config['SOCK_SERVER_OPTIONS'] = {'ping_interval': 10}
|
||||||
|
# define global MODEM_VERSION
|
||||||
|
app.MODEM_VERSION = MODEM_VERSION
|
||||||
|
|
||||||
|
config_file = set_config()
|
||||||
|
app.config_manager = CONFIG(config_file)
|
||||||
|
|
||||||
|
# start modem
|
||||||
|
app.state_queue = queue.Queue() # queue which holds latest states
|
||||||
|
app.modem_events = queue.Queue() # queue which holds latest events
|
||||||
|
app.modem_fft = queue.Queue() # queue which holds latest fft data
|
||||||
|
app.modem_service = queue.Queue() # start / stop modem service
|
||||||
|
app.event_manager = event_manager.EventManager([app.modem_events]) # TODO remove the app.modem_event custom queue
|
||||||
|
# init state manager
|
||||||
|
app.state_manager = state_manager.StateManager(app.state_queue)
|
||||||
|
# start service manager
|
||||||
|
app.service_manager = service_manager.SM(app)
|
||||||
|
# start modem service
|
||||||
|
app.modem_service.put("start")
|
||||||
|
|
||||||
|
wsm.startThreads(app)
|
||||||
app.run()
|
app.run()
|
||||||
|
|
|
@ -13,7 +13,8 @@ class TestIntegration(unittest.TestCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
cmd = "flask --app modem/server run"
|
#cmd = "flask --app modem/server run"
|
||||||
|
cmd = "python3 modem/server.py"
|
||||||
my_env = os.environ.copy()
|
my_env = os.environ.copy()
|
||||||
my_env["FREEDATA_CONFIG"] = "modem/config.ini.example"
|
my_env["FREEDATA_CONFIG"] = "modem/config.ini.example"
|
||||||
cls.process = Popen(shlex.split(cmd), stdin=PIPE, env=my_env)
|
cls.process = Popen(shlex.split(cmd), stdin=PIPE, env=my_env)
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
FREEDATA_CONFIG=modem/config.ini flask --app modem/server run
|
# FREEDATA_CONFIG=modem/config.ini flask --app modem/server run
|
||||||
|
FREEDATA_CONFIG=modem/config.ini python3 modem/server.py
|
||||||
|
|
Loading…
Reference in New Issue