Report the VASSAL and VASL versions when analyzing .vsav files.

master
Pacman Ghost 2 years ago
parent 0ab71fb70e
commit 0cbce2182c
  1. 13
      vasl_templates/webapp/static/vassal.js
  2. 21
      vasl_templates/webapp/vassal.py

@ -402,7 +402,7 @@ function _create_vo_entries_from_analysis( report )
// add a vehicle/ordnance for each relevant GPID
var nCreated = 0 ;
gpids = Object.keys( report ) ;
gpids = Object.keys( report.pieces ) ;
for ( i=0 ; i < gpids.length ; ++i ) {
var gpid = gpids[ i ] ;
var entry = chooseEntry( gpid ) ;
@ -421,6 +421,17 @@ function _create_vo_entries_from_analysis( report )
[ create_vo_entries( 2, "vehicles" ), create_vo_entries( 2, "ordnance" ) ]
] ;
// report the VASSAL and VASL versions
// NOTE: We don't do this during the test suite since it can only store 1 message at a time :-/
// It would be nice to test this functionality, but the implemenation is simple, so we can live without it.
if ( ! getUrlParam( "store_msgs" ) ) {
showInfoMsg( "The scenario was created with: <ul style='margin-top:0;'>" +
"<li> VASSAL " + report.vassal_version +
" <li> VASL " + report.vasl_version +
" </ul>"
) ;
}
// report what happened
var report_strings = [] ;
function make_report_string( nat, nVehicles, nOrdnance ) {

@ -12,6 +12,8 @@ import logging
import pprint
import base64
import time
import io
import zipfile
import xml.etree.cElementTree as ET
from flask import request, jsonify
@ -227,7 +229,7 @@ def _parse_label_report( fname ):
# ---------------------------------------------------------------------
@app.route( "/analyze-vsav", methods=["POST"] )
def analyze_vsav():
def analyze_vsav(): #pylint: disable=too-many-locals
"""Analyze a VASL scenario file."""
# parse the request
@ -272,13 +274,24 @@ def analyze_vsav():
# and it contains pieces that had their GPID's changed from 6.4.4. This kind of nonsense
# is probably unsustainable over the long-term, but we try to maintain some semblance of
# back-compatibility for as long as we can :-/
report2 = {}
report2 = { "pieces": {} }
for gpid,vals in report.items():
orig_gpid = get_reverse_remapped_gpid( globvars.vasl_mod, gpid )
if orig_gpid == gpid:
report2[ gpid ] = vals
report2["pieces"][ gpid ] = vals
else:
report2[ orig_gpid ] = vals
report2["pieces"][ orig_gpid ] = vals
# extract the VASSAL and VASL versions from the VSAV data
def get_node_text( key, node_name ):
elem = doc.find( "./{}".format( node_name ) )
if elem is not None:
report2[ key ] = elem.text
with zipfile.ZipFile( io.BytesIO( vsav_data ) ) as zfile:
module_data = zfile.read( "moduledata" )
doc = ET.parse( io.BytesIO( module_data ) )
get_node_text( "vassal_version", "VassalVersion" )
get_node_text( "vasl_version", "version" )
# return the results
logger.info( "Analyzed the VSAV file OK: elapsed=%.3fs\n%s",

Loading…
Cancel
Save