|
@@ -1,16 +1,12 @@
|
|
|
-import eventlet
|
|
|
import os
|
|
|
-import socketio
|
|
|
|
|
|
from glob import glob
|
|
|
-from os import getcwd
|
|
|
-from os import path
|
|
|
-from os.path import exists
|
|
|
|
|
|
-from flask import Flask
|
|
|
+import eventlet
|
|
|
+import socketio
|
|
|
+
|
|
|
from flask import send_from_directory
|
|
|
|
|
|
-from pycs import app
|
|
|
from pycs.database.Model import Model
|
|
|
from pycs.database.LabelProvider import LabelProvider
|
|
|
from pycs.frontend.endpoints.ListJobs import ListJobs
|
|
@@ -64,10 +60,10 @@ class WebServer:
|
|
|
|
|
|
def __init__(self, app, settings: dict, discovery: bool = True):
|
|
|
|
|
|
- PRODUCTION = os.path.exists('webui/index.html')
|
|
|
+ is_production = os.path.exists('webui/index.html')
|
|
|
|
|
|
# initialize web server
|
|
|
- if PRODUCTION:
|
|
|
+ if is_production:
|
|
|
print('production build')
|
|
|
|
|
|
# find static files and folders
|
|
@@ -89,13 +85,13 @@ class WebServer:
|
|
|
else:
|
|
|
self.__sio = socketio.Server(async_mode='eventlet')
|
|
|
|
|
|
- self.__app = socketio.WSGIApp(self.__sio, app, static_files=static_files)
|
|
|
+ self.wsgi_app = socketio.WSGIApp(self.__sio, app, static_files=static_files)
|
|
|
|
|
|
# overwrite root path to serve index.html
|
|
|
@app.route('/', methods=['GET'])
|
|
|
def index():
|
|
|
# pylint: disable=unused-variable
|
|
|
- return send_from_directory(path.join(getcwd(), 'webui'), 'index.html')
|
|
|
+ return send_from_directory(os.path.join(os.getcwd(), 'webui'), 'index.html')
|
|
|
|
|
|
else:
|
|
|
print('development build')
|
|
@@ -137,6 +133,7 @@ class WebServer:
|
|
|
|
|
|
|
|
|
def define_routes(self, jobs, notifications, pipelines):
|
|
|
+ """ defines app routes """
|
|
|
|
|
|
# additional
|
|
|
self.app.add_url_rule(
|
|
@@ -295,7 +292,8 @@ class WebServer:
|
|
|
)
|
|
|
self.app.add_url_rule(
|
|
|
'/projects/<int:project_id>/external_storage',
|
|
|
- view_func=ExecuteExternalStorage.as_view('execute_external_storage', notifications, jobs)
|
|
|
+ view_func=ExecuteExternalStorage.as_view('execute_external_storage',
|
|
|
+ notifications, jobs)
|
|
|
)
|
|
|
self.app.add_url_rule(
|
|
|
'/projects/<int:project_id>/remove',
|
|
@@ -326,5 +324,5 @@ class WebServer:
|
|
|
)
|
|
|
|
|
|
def run(self):
|
|
|
- # finally start web server
|
|
|
+ """ start web server """
|
|
|
eventlet.wsgi.server(eventlet.listen((self.host, self.port)), self.wsgi_app)
|