Skip to content

Commit

Permalink
Refactored to get server running again
Browse files Browse the repository at this point in the history
  • Loading branch information
btr1975 committed May 18, 2021
1 parent f391b6c commit 21cb5b4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
9 changes: 4 additions & 5 deletions qct/scripts/qct_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ def post(self): # pylint: disable=no-self-use
return template_engine_obj.get_remote_yaml_template()


# TODO: Change var ip
def run_local_server(ip, port, base_api_uri, debug, directories): # pylint: disable=invalid-name
def run_local_server(ip_addr, port, base_api_uri, debug, directories):
"""
Function to run the local flask server
:param ip: The IP address to listen on
:param ip_addr: The IP address to listen on
:param port: The port to listen on
:param base_api_uri: The base uri, for the server
:param debug: True to turn on debug
Expand All @@ -85,15 +84,15 @@ def run_local_server(ip, port, base_api_uri, debug, directories): # pylint: dis
if debug:
LOGGER.setLevel(logging.DEBUG)
LOGGER.debug('Starting server with the following ip: %s, '
'port: %s, base_api_uri: %s, server_debug: %s', ip, port, base_api_uri, debug)
'port: %s, base_api_uri: %s, server_debug: %s', ip_addr, port, base_api_uri, debug)
# TODO: Need to check on this global usage
global DIRECTORIES # pylint: disable=global-statement
DIRECTORIES = directories
app = Flask(__name__)
api = Api(app)
api.add_resource(PostBasicBuild, '{base_api_uri}/basic_build'.format(base_api_uri=base_api_uri))
api.add_resource(PostRemoteYamlBuild, '{base_api_uri}/remote_yaml_build'.format(base_api_uri=base_api_uri))
app.run(port=int(port), host=ip, debug=debug)
app.run(port=int(port), host=ip_addr, debug=debug)


# https://blog.miguelgrinberg.com/post/designing-a-restful-api-using-flask-restful
4 changes: 2 additions & 2 deletions qct/scripts/template_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import yaml
from .arestme import ARestMe
from ..utils import custom_filters
from ..version import __version__


LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -506,8 +507,7 @@ def server_rest(self): # pylint: disable=too-many-branches
rest_object.set_server_and_port(server_config.get('protocol'), server_config.get('server_host'),
server_config.get('server_port'))
rest_object.set_update_headers('Qct', 'ApiVersion1')
# TODO: Need to get version from somewhere else
# rest_object.set_update_headers('Qct-Te', __version__)
rest_object.set_update_headers('Qct-Te', __version__)

if yaml_data.get('remote_build_server_yaml_template'):
response_data = rest_object.send_post('{server_api_uri}remote_yaml_'
Expand Down
3 changes: 3 additions & 0 deletions qct/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Holds package version information
"""
__title__ = 'QuickConfigTemplates'
__description__ = 'Creates configuration from YAML'
__author__ = 'Benjamin P. Trachtenberg'
Expand Down

0 comments on commit 21cb5b4

Please sign in to comment.