Updated the Server Settings dialog for the new features.

master
Pacman Ghost 5 years ago
parent 835c376603
commit ed14c063c1
  1. 2
      docker/config/debug.cfg
  2. 4
      docker/config/site.cfg
  3. 98
      vasl_templates/server_settings.py
  4. 456
      vasl_templates/ui/server_settings.ui
  5. 16
      vasl_templates/webapp/config/site.cfg.example
  6. 2
      vasl_templates/webapp/file_server/vasl_mod.py
  7. 12
      vasl_templates/webapp/tests/remote.py
  8. 4
      vasl_templates/webapp/vo_notes.py

@ -1,4 +1,4 @@
[Debug]
TEST_VASL_MODS = /test-data/vasl-vmods/
TEST_VASL_EXTENSIONS_DIR = /test-data/vasl-extensions/
TEST_VASL_EXTNS_DIR = /test-data/vasl-extensions/

@ -3,5 +3,5 @@
FLASK_HOST = 0.0.0.0
VASL_MOD = /data/vasl.vmod
VASL_EXTENSIONS = /data/vasl-extensions/
CHAPTER_H_NOTES = /data/chapter-h-notes/
VASL_EXTNS_DIR = /data/vasl-extensions/
CHAPTER_H_NOTES_DIR = /data/chapter-h-notes/

@ -3,7 +3,7 @@
import os
from PyQt5 import uic
from PyQt5.QtWidgets import QDialog, QFileDialog
from PyQt5.QtWidgets import QDialog, QFileDialog, QGroupBox
from PyQt5.QtGui import QIcon
from vasl_templates.main import app_settings
@ -27,21 +27,36 @@ class ServerSettingsDialog( QDialog ):
base_dir = os.path.split( __file__ )[0]
dname = os.path.join( base_dir, "ui/server_settings.ui" )
uic.loadUi( dname, self )
for btn in ["vassal_dir","vasl_mod","boards_dir","java","webdriver"]:
for btn in ["vassal_dir", "vasl_mod", "vasl_extns_dir", "boards_dir",
"java", "webdriver",
"chapter_h_notes_dir", "user_files_dir"
]:
getattr( self, "select_{}_button".format(btn) ).setIcon(
QIcon( os.path.join( base_dir, "resources/file_browser.png" ) )
)
self.setMinimumSize( self.size() )
self.setFixedSize( self.size() )
# initialize the UI
for attr in dir(self):
attr = getattr( self, attr )
if isinstance( attr, QGroupBox ):
attr.setStyleSheet("QGroupBox { font-weight: bold; } ")
# initialize handlers
self.select_vassal_dir_button.clicked.connect( self.on_select_vassal_dir )
self.select_vasl_mod_button.clicked.connect( self.on_select_vasl_mod )
self.select_vasl_extns_dir_button.clicked.connect( self.on_select_vasl_extns_dir )
self.select_boards_dir_button.clicked.connect( self.on_select_boards_dir )
self.select_java_button.clicked.connect( self.on_select_java )
self.select_webdriver_button.clicked.connect( self.on_select_webdriver )
self.select_chapter_h_notes_dir_button.clicked.connect( self.on_select_chapter_h_notes_dir )
self.select_user_files_dir_button.clicked.connect( self.on_select_user_files_dir )
self.ok_button.clicked.connect( self.on_ok )
self.cancel_button.clicked.connect( self.on_cancel )
# initialize handlers
self.chapter_h_notes_dir.textChanged.connect( self.on_chapter_h_notes_dir_changed )
# load the current server settings
self.vassal_dir.setText( app_settings.value( "ServerSettings/vassal-dir" ) )
self.vassal_dir.setToolTip(
@ -51,10 +66,16 @@ class ServerSettingsDialog( QDialog ):
self.vasl_mod.setToolTip(
"Supported versions: {}".format( SUPPORTED_VASL_MOD_VERSIONS_DISPLAY )
)
self.vasl_extns_dir.setText( app_settings.value( "ServerSettings/vasl-extns-dir" ) )
self.boards_dir.setText( app_settings.value( "ServerSettings/boards-dir" ) )
self.java_path.setText( app_settings.value( "ServerSettings/java-path" ) )
self.webdriver_path.setText( app_settings.value( "ServerSettings/webdriver-path" ) )
self.webdriver_path.setToolTip( "Configure either geckodriver or chromedriver here." )
self.chapter_h_notes_dir.setText( app_settings.value( "ServerSettings/chapter-h-notes-dir" ) )
scaling = app_settings.value( "ServerSettings/chapter-h-image-scaling" )
if scaling:
self.chapter_h_image_scaling.setText( str( scaling ) )
self.user_files_dir.setText( app_settings.value( "ServerSettings/user-files-dir" ) )
def on_select_vassal_dir( self ):
"""Let the user locate the VASSAL installation directory."""
@ -76,6 +97,16 @@ class ServerSettingsDialog( QDialog ):
if fname:
self.vasl_mod.setText( fname )
def on_select_vasl_extns_dir( self ):
"""Let the user locate the VASL extensions directory."""
dname = QFileDialog.getExistingDirectory(
self, "Select VASL extensions directory",
self.vasl_extns_dir.text(),
QFileDialog.ShowDirsOnly
)
if dname:
self.vasl_extns_dir.setText( dname )
def on_select_boards_dir( self ):
"""Let the user locate the VASL boards directory."""
dname = QFileDialog.getExistingDirectory(
@ -99,24 +130,58 @@ class ServerSettingsDialog( QDialog ):
def on_select_webdriver( self ):
"""Let the user locate the webdriver executable."""
fname = QFileDialog.getOpenFileName(
self, "Select webdriver",
self, "Select webdriver executable",
self.webdriver_path.text(),
_make_exe_filter_string()
)[0]
if fname:
self.webdriver_path.setText( fname )
def on_select_chapter_h_notes_dir( self ):
"""Let the user locate their Chapter H notes directory."""
dname = QFileDialog.getExistingDirectory(
self, "Select Chapter H notes directory",
self.chapter_h_notes_dir.text(),
QFileDialog.ShowDirsOnly
)
if dname:
self.chapter_h_notes_dir.setText( dname )
def on_select_user_files_dir( self ):
"""Let the user locate their user files directory."""
dname = QFileDialog.getExistingDirectory(
self, "Select user files directory",
self.user_files_dir.text(),
QFileDialog.ShowDirsOnly
)
if dname:
self.user_files_dir.setText( dname )
def on_ok( self ):
"""Accept the new server settings."""
# unload the dialog
try:
chapter_h_image_scaling = self.chapter_h_image_scaling.text().strip()
if chapter_h_image_scaling:
chapter_h_image_scaling = int( self.chapter_h_image_scaling.text() )
except ValueError:
MainWindow.showErrorMsg( "Image scaling must be a numeric percentage value." )
self.chapter_h_image_scaling.setFocus()
return
# save the new settings
app_settings.setValue( "ServerSettings/vassal-dir", self.vassal_dir.text() )
fname = self.vasl_mod.text().strip()
vasl_mod_changed = fname != app_settings.value( "ServerSettings/vasl-mod", "" )
app_settings.setValue( "ServerSettings/vasl-mod", fname )
app_settings.setValue( "ServerSettings/vasl-extns-dir", self.vasl_extns_dir.text() )
app_settings.setValue( "ServerSettings/boards-dir", self.boards_dir.text() )
app_settings.setValue( "ServerSettings/java-path", self.java_path.text() )
app_settings.setValue( "ServerSettings/webdriver-path", self.webdriver_path.text() )
app_settings.setValue( "ServerSettings/chapter-h-notes-dir", self.chapter_h_notes_dir.text() )
app_settings.setValue( "ServerSettings/chapter-h-image-scaling", chapter_h_image_scaling )
app_settings.setValue( "ServerSettings/user-files-dir", self.user_files_dir.text() )
# install the new settings
# NOTE: We should really do this before saving the new settings, but that's more trouble
@ -138,6 +203,17 @@ class ServerSettingsDialog( QDialog ):
"""Cancel the dialog."""
self.close()
def update_ui( self ):
"""Update the UI."""
rc = self.chapter_h_notes_dir.text().strip() != ""
self.chapter_h_image_scaling_label.setEnabled( rc )
self.chapter_h_image_scaling_label2.setEnabled( rc )
self.chapter_h_image_scaling.setEnabled( rc )
def on_chapter_h_notes_dir_changed( self, val ): #pylint: disable=unused-argument
"""Called when the Chapter H notes directory is changed."""
self.update_ui()
def _make_exe_filter_string():
"""Make a file filter string for executables."""
buf = []
@ -153,11 +229,15 @@ def install_server_settings( is_startup ):
# install the server settings
from vasl_templates.webapp import app as app
app.config["VASSAL_DIR"] = app_settings.value( "ServerSettings/vassal-dir" )
app.config["VASL_MOD"] = app_settings.value( "ServerSettings/vasl-mod" )
app.config["BOARDS_DIR"] = app_settings.value( "ServerSettings/boards-dir" )
app.config["JAVA_PATH"] = app_settings.value( "ServerSettings/java-path" )
app.config["WEBDRIVER_PATH"] = app_settings.value( "ServerSettings/webdriver-path" )
app.config[ "VASSAL_DIR" ] = app_settings.value( "ServerSettings/vassal-dir" )
app.config[ "VASL_MOD" ] = app_settings.value( "ServerSettings/vasl-mod" )
app.config[ "VASL_EXTNS_DIR" ] = app_settings.value( "ServerSettings/vasl-extns-dir" )
app.config[ "BOARDS_DIR" ] = app_settings.value( "ServerSettings/boards-dir" )
app.config[ "JAVA_PATH" ] = app_settings.value( "ServerSettings/java-path" )
app.config[ "WEBDRIVER_PATH" ] = app_settings.value( "ServerSettings/webdriver-path" )
app.config[ "CHAPTER_H_NOTES_DIR" ] = app_settings.value( "ServerSettings/chapter-h-notes-dir" )
app.config[ "CHAPTER_H_IMAGE_SCALING" ] = app_settings.value( "ServerSettings/chapter-h-image-scaling" )
app.config[ "USER_FILES_DIR" ] = app_settings.value( "ServerSettings/user-files-dir" )
# initialize
if is_startup:

@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>199</height>
<width>831</width>
<height>271</height>
</rect>
</property>
<property name="windowTitle">
@ -19,8 +19,142 @@
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>170</y>
<width>401</width>
<height>91</height>
</rect>
</property>
<property name="title">
<string>Support programs</string>
</property>
<widget class="QWidget" name="formLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>381</width>
<height>51</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout_3">
<property name="horizontalSpacing">
<number>2</number>
</property>
<property name="verticalSpacing">
<number>2</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>&amp;Java:</string>
</property>
<property name="buddy">
<cstring>java_path</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QLineEdit" name="java_path"/>
</item>
<item>
<widget class="QPushButton" name="select_java_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>&amp;Web driver:</string>
</property>
<property name="buddy">
<cstring>webdriver_path</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QLineEdit" name="webdriver_path"/>
</item>
<item>
<widget class="QPushButton" name="select_webdriver_button">
<property name="minimumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>401</width>
<height>151</height>
</rect>
</property>
<property name="title">
<string>VASSAL/VASL</string>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>381</width>
<height>111</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="verticalSpacing">
<number>2</number>
@ -113,25 +247,25 @@
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="label_6">
<property name="text">
<string>VASL &amp;boards:</string>
<string>VASL e&amp;xtensions:</string>
</property>
<property name="buddy">
<cstring>boards_dir</cstring>
<cstring>vasl_extns_dir</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QLineEdit" name="boards_dir"/>
<widget class="QLineEdit" name="vasl_extns_dir"/>
</item>
<item>
<widget class="QPushButton" name="select_boards_dir_button">
<widget class="QPushButton" name="select_vasl_extns_dir_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -158,25 +292,25 @@
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&amp;Java:</string>
<string>VASL &amp;boards:</string>
</property>
<property name="buddy">
<cstring>java_path</cstring>
<cstring>boards_dir</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QLineEdit" name="java_path"/>
<widget class="QLineEdit" name="boards_dir"/>
</item>
<item>
<widget class="QPushButton" name="select_java_button">
<widget class="QPushButton" name="select_boards_dir_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -202,26 +336,90 @@
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
</layout>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_3">
<property name="geometry">
<rect>
<x>420</x>
<y>10</y>
<width>401</width>
<height>121</height>
</rect>
</property>
<property name="title">
<string>User data</string>
</property>
<widget class="QWidget" name="formLayoutWidget_2">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>381</width>
<height>81</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout_4">
<property name="horizontalSpacing">
<number>2</number>
</property>
<property name="verticalSpacing">
<number>2</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>&amp;Web driver:</string>
<string>Chapter &amp;H notes:</string>
</property>
<property name="buddy">
<cstring>webdriver_path</cstring>
<cstring>chapter_h_notes_dir</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="spacing">
<number>2</number>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="chapter_h_notes_dir"/>
</item>
<item>
<widget class="QPushButton" name="select_chapter_h_notes_dir_button">
<property name="minimumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>User &amp;files:</string>
</property>
<property name="buddy">
<cstring>user_files_dir</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLineEdit" name="webdriver_path"/>
<widget class="QLineEdit" name="user_files_dir"/>
</item>
<item>
<widget class="QPushButton" name="select_webdriver_button">
<widget class="QPushButton" name="select_user_files_dir_button">
<property name="minimumSize">
<size>
<width>22</width>
@ -241,98 +439,148 @@
</item>
</layout>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="chapter_h_image_scaling_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>DejaVu Sans</family>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>Image s&amp;caling:</string>
</property>
<property name="buddy">
<cstring>chapter_h_image_scaling</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="chapter_h_image_scaling">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<family>DejaVu Sans</family>
<pointsize>8</pointsize>
</font>
</property>
<property name="inputMask">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="chapter_h_image_scaling_label2">
<property name="text">
<string>%</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>5</number>
</widget>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_3">
<property name="geometry">
<rect>
<x>650</x>
<y>230</y>
<width>164</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QPushButton" name="ok_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="leftMargin">
<number>0</number>
<property name="text">
<string>OK</string>
</property>
<property name="topMargin">
<number>0</number>
<property name="default">
<bool>true</bool>
</property>
<property name="rightMargin">
<number>0</number>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancel_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="bottomMargin">
<number>0</number>
<property name="text">
<string>Cancel</string>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>309</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="ok_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>OK</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancel_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
<tabstops>
<tabstop>vassal_dir</tabstop>
<tabstop>select_vassal_dir_button</tabstop>
<tabstop>vasl_mod</tabstop>
<tabstop>select_vasl_mod_button</tabstop>
<tabstop>vasl_extns_dir</tabstop>
<tabstop>select_vasl_extns_dir_button</tabstop>
<tabstop>boards_dir</tabstop>
<tabstop>select_boards_dir_button</tabstop>
<tabstop>chapter_h_notes_dir</tabstop>
<tabstop>select_chapter_h_notes_dir_button</tabstop>
<tabstop>chapter_h_image_scaling</tabstop>
<tabstop>user_files_dir</tabstop>
<tabstop>select_user_files_dir_button</tabstop>
<tabstop>java_path</tabstop>
<tabstop>select_java_button</tabstop>
<tabstop>webdriver_path</tabstop>

@ -1,12 +1,16 @@
[Site Config]
; Enable VASL counter images in the UI by configuring a VASL .vmod file here.
VASL_MOD = ...configure the VASL module (e.g. vasl-6.4.3.vmod)...
; Configure VASSAL to be able to automatically update labels in a VASL scenario.
; configure VASSAL and VASL
VASSAL_DIR = ...configure the VASSAL installation directory...
VASL_MOD = ...configure the VASL module (e.g. vasl-6.4.3.vmod)...
VASL_EXTNS_DIR = ...configured the VASL extensions directory...
BOARDS_DIR = ...configure the VASL boards directory...
WEBDRIVER_PATH = ...configure either geckodriver or chromedriver here...
; configure support prorams
; JAVA_PATH = ...configure the Java executable here (optional, must be in the PATH otherwise)...
WEBDRIVER_PATH = ...configure either geckodriver or chromedriver here...
CHAPTER_H_NOTES = ...configure your Chapter H vehicle/ordnance images and multi-applicable notes...
; configure your user data
CHAPTER_H_NOTES_DIR = ...configure your Chapter H vehicle/ordnance images and multi-applicable notes...
; CHAPTER_H_IMAGE_SCALING = ...optional scaling percentage for Chapter H images...
USER_FILES_DIR = ...configure your user files directory...

@ -53,7 +53,7 @@ def set_vasl_mod( vmod_fname, msg_store ):
with _vasl_mod_lock:
global _vasl_mod
if vmod_fname:
extns_dir = app.config.get( "VASL_EXTENSIONS_DIR" )
extns_dir = app.config.get( "VASL_EXTNS_DIR" )
extns = _load_vasl_extns( extns_dir )
_vasl_mod = VaslMod( vmod_fname, DATA_DIR, extns )
if _vasl_mod.vasl_version not in SUPPORTED_VASL_MOD_VERSIONS:

@ -28,7 +28,7 @@ from vasl_templates.webapp.file_server import vasl_mod as vasl_mod_module
_logger = logging.getLogger( "control_tests" )
_ORIG_CHAPTER_H_NOTES = app.config.get( "CHAPTER_H_NOTES" )
_ORIG_CHAPTER_H_NOTES_DIR = app.config.get( "CHAPTER_H_NOTES_DIR" )
# ---------------------------------------------------------------------
@ -146,16 +146,16 @@ class ControlTests:
try:
dname = pytest.config.option.vasl_extensions #pylint: disable=no-member
except AttributeError:
dname = app.config[ "TEST_VASL_EXTENSIONS_DIR" ]
dname = app.config[ "TEST_VASL_EXTNS_DIR" ]
elif extns_dtype == "test":
dname = self._vasl_extns_temp_dir.name
else:
assert False, "Unknown extensions directory type: "+extns_dtype
_logger.info( "Enabling VASL extensions: %s", dname )
app.config[ "VASL_EXTENSIONS_DIR" ] = dname
app.config[ "VASL_EXTNS_DIR" ] = dname
else:
_logger.info( "Disabling VASL extensions." )
app.config.pop( "VASL_EXTENSIONS_DIR", None )
app.config.pop( "VASL_EXTNS_DIR", None )
# configure the VASL module
if vmod:
@ -241,14 +241,14 @@ class ControlTests:
def _set_vo_notes_dir( self, dtype=None ):
"""Set the vehicle/ordnance notes directory."""
if dtype == "real":
dname = _ORIG_CHAPTER_H_NOTES
dname = _ORIG_CHAPTER_H_NOTES_DIR
elif dtype == "test":
dname = os.path.join( os.path.split(__file__)[0], "fixtures/vo-notes" )
else:
assert dtype is None
dname = None
_logger.info( "Setting vehicle/ordnance notes: %s", dname )
app.config["CHAPTER_H_NOTES"] = dname
app.config["CHAPTER_H_NOTES_DIR"] = dname
with webapp_vo_notes._vo_notes_lock: #pylint: disable=protected-access
webapp_vo_notes._cached_vo_notes = None #pylint: disable=protected-access
webapp_vo_notes._vo_notes_file_server = None #pylint: disable=protected-access

@ -42,7 +42,7 @@ def _do_get_vo_notes( vo_type ): #pylint: disable=too-many-locals,too-many-branc
return _cached_vo_notes[ vo_type ]
# locate the data directory
dname = app.config.get( "CHAPTER_H_NOTES" )
dname = app.config.get( "CHAPTER_H_NOTES_DIR" )
if not dname:
return {}
dname = os.path.abspath( dname )
@ -125,7 +125,7 @@ def get_vo_note( vo_type, nat, key ):
fname = vo_notes.get( nat, {} ).get( key )
resp = _vo_notes_file_server.serve_file( fname )
default_scaling = app.config.get( "CHAPTER_H_NOTE_SCALING", 100 )
default_scaling = app.config.get( "CHAPTER_H_IMAGE_SCALING", 100 )
return resize_image_response( resp, default_scaling=default_scaling )
# ---------------------------------------------------------------------

Loading…
Cancel
Save