diff --git a/vasl_templates/webapp/file_server/vasl_mod.py b/vasl_templates/webapp/file_server/vasl_mod.py index f91936d..a878f98 100644 --- a/vasl_templates/webapp/file_server/vasl_mod.py +++ b/vasl_templates/webapp/file_server/vasl_mod.py @@ -25,7 +25,9 @@ class VaslMod: # parse the VASL module file _logger.info( "Loading VASL module: %s", fname ) self.zip_file = zipfile.ZipFile( fname, "r" ) - self._parse_vmod( data_dir ) + self.vasl_version = self._parse_vmod( data_dir ) + if self.vasl_version not in SUPPORTED_VASL_MOD_VERSIONS: + _logger.warning( "Unsupported VASL version: %s", self.vasl_version ) def get_piece_image( self, gpid, side, index ): """Get the image for the specified piece.""" @@ -92,8 +94,6 @@ class VaslMod: # parse the VASL build info build_info = self.zip_file.read( "buildFile" ) doc = xml.etree.ElementTree.fromstring( build_info ) - if doc.attrib.get( "version" ) not in SUPPORTED_VASL_MOD_VERSIONS: - _logger.warning( "Unsupported VASL version: %s", doc.attrib.get("version") ) for node in doc.iter( "VASSAL.build.widget.PieceSlot" ): # load the next entry @@ -149,6 +149,8 @@ class VaslMod: gpids = ", ".join( expected_multiple_images.keys() ) _logger.warning( "Expected multiple images but didn't find them: %s", gpids ) + return doc.attrib.get( "version" ) + @staticmethod def _get_image_paths( gpid, val ): #pylint: disable=too-many-branches """Get the image path(s) for a piece.""" diff --git a/vasl_templates/webapp/static/main.js b/vasl_templates/webapp/static/main.js index 6899c61..e65e793 100644 --- a/vasl_templates/webapp/static/main.js +++ b/vasl_templates/webapp/static/main.js @@ -268,6 +268,21 @@ $(document).ready( function () { showErrorMsg( "Can't get the template pack:
Things might work, but they might not...".format( version ) + return "" + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +@app.route( "/check-vasl-version" ) +def check_vasl_version(): + """Check if we're running a supported version of VASL.""" + if vasl_mod and vasl_mod.vasl_version not in SUPPORTED_VASL_MOD_VERSIONS: + return "VASL {} is unsupported.
Things might work, but they might not...".format( vasl_mod.vasl_version ) + return "" diff --git a/vassal-shim/release/vassal-shim.jar b/vassal-shim/release/vassal-shim.jar index e1d4324..9c45bc3 100644 Binary files a/vassal-shim/release/vassal-shim.jar and b/vassal-shim/release/vassal-shim.jar differ diff --git a/vassal-shim/src/vassal_shim/Main.java b/vassal-shim/src/vassal_shim/Main.java index f8ba7e6..299a215 100644 --- a/vassal-shim/src/vassal_shim/Main.java +++ b/vassal-shim/src/vassal_shim/Main.java @@ -1,5 +1,10 @@ package vassal_shim ; +import java.io.BufferedWriter ; +import java.io.FileWriter ; + +import VASSAL.Info ; + import vassal_shim.VassalShim ; // -------------------------------------------------------------------- @@ -29,6 +34,15 @@ public class Main shim.updateScenario( args[3], args[4], args[5], args[6] ) ; System.exit( 0 ) ; } + else if ( cmd.equals( "version" ) ) { + checkArgs( args, 2, "the output file" ) ; + System.out.println( Info.getVersion() ) ; + // FUDGE! The Python web server can't capture output on Windows - save the result to a file as well :-/ + BufferedWriter writer = new BufferedWriter( new FileWriter( args[1] ) ) ; + writer.write( Info.getVersion() ) ; + writer.close() ; + System.exit( 0 ) ; + } else { System.out.println( "Unknown command: " + cmd ) ; System.exit( 1 ) ;