Issue #2667 delta scripts for lightning source name change in xml files
handles stored procedures/bundles in localization Former-commit-id:ddcb1011bb
[formerly 8e3e3be372d5db6dfc5897407074bc250fbef294] Former-commit-id:0811b0580f
This commit is contained in:
parent
e74625dcca
commit
cc50637346
5 changed files with 114 additions and 0 deletions
9
deltaScripts/14.3.1/renameLightningSourceInBundles.sh
Executable file
9
deltaScripts/14.3.1/renameLightningSourceInBundles.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script will rename the lightning source column in any D2D bundle files
|
||||
# This update is only for edex servers which host the cave localization files
|
||||
|
||||
MY_DIR=`dirname $0`
|
||||
bash $MY_DIR/utility/updateLightningNameInXML.sh -b
|
||||
exit 0
|
||||
|
9
deltaScripts/14.3.1/renameLightningSourceInProcedures.sh
Executable file
9
deltaScripts/14.3.1/renameLightningSourceInProcedures.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script will rename the lightning source column in any D2D procedure files
|
||||
# This update is only for edex servers which host the cave localization files
|
||||
|
||||
MY_DIR=`dirname $0`
|
||||
bash $MY_DIR/utility/updateLightningNameInXML.sh -p
|
||||
exit 0
|
||||
|
32
deltaScripts/14.3.1/utility/replaceAttributeInXML.py
Executable file
32
deltaScripts/14.3.1/utility/replaceAttributeInXML.py
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env python
|
||||
# This script will replace attribute values for XML elements that match an xpath
|
||||
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
if len(sys.argv) != 6:
|
||||
print "Usage: %s [xml inputfile file] [output file name] [xpath] [attribute name] [replacement value]" % (sys.argv[0])
|
||||
sys.exit(1)
|
||||
|
||||
print "Parsing XML file at " + sys.argv[1]
|
||||
tree = ET.parse(sys.argv[1])
|
||||
root = tree.getroot()
|
||||
|
||||
matches = root.findall(sys.argv[3])
|
||||
|
||||
if len(matches) < 1:
|
||||
print "No matches found, exiting"
|
||||
sys.exit(0)
|
||||
|
||||
attribute = sys.argv[4]
|
||||
replValue = sys.argv[5]
|
||||
|
||||
for match in matches:
|
||||
if attribute in match.attrib:
|
||||
print "Replacing attribute '%s': old value '%s', new value '%s'" % \
|
||||
(attribute, match.attrib[attribute], replValue)
|
||||
match.attrib[attribute] = replValue
|
||||
|
||||
print "Writing results to file at " + sys.argv[2]
|
||||
tree.write(sys.argv[2])
|
||||
print "Done"
|
64
deltaScripts/14.3.1/utility/updateLightningNameInXML.sh
Executable file
64
deltaScripts/14.3.1/utility/updateLightningNameInXML.sh
Executable file
|
@ -0,0 +1,64 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script will rename the lightning source column in any D2D bundle/procedure files
|
||||
# This update is only for edex servers which host the cave localization files
|
||||
|
||||
function usage()
|
||||
{
|
||||
echo "Usage: $0 [-p|-b]"
|
||||
echo "Use '$0 -p to update procedure files"
|
||||
echo "Use '$0 -b to update bundle files"
|
||||
}
|
||||
|
||||
if [[ $# < 1 ]]
|
||||
then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IFS=$'\n'
|
||||
if [[ $1 == '-b' ]]
|
||||
then
|
||||
files=`find /awips2/edex/data/utility/cave_static/*/*/bundles/ -iname '*.xml'`
|
||||
elif [[ $1 == '-p' ]]
|
||||
then
|
||||
files=`ls /awips2/edex/data/utility/cave_static/*/*/procedures/*.xml`
|
||||
else
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "No files found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Press Enter to perform the updates Ctrl-C to quit."
|
||||
read done
|
||||
|
||||
xpath=".//resourceData[@{http://www.w3.org/2001/XMLSchema-instance}type='lightningResourceData']//mapping[@key='lightSource']"
|
||||
attributeName="key"
|
||||
replValue="source"
|
||||
|
||||
MY_DIR=`dirname $0`
|
||||
for f in $files; do
|
||||
python $MY_DIR/replaceAttributeInXML.py $f $f.tmp $xpath $attributeName $replValue
|
||||
if [[ $? == 0 ]]
|
||||
then
|
||||
# if output file doesn't exist, xpath wasn't found
|
||||
if [[ -e $f.tmp ]]
|
||||
then
|
||||
mv $f.tmp $f
|
||||
fi
|
||||
else
|
||||
echo "ERROR: Problem updating file $f"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
echo "INFO: The update finished successfully."
|
||||
exit 0
|
||||
|
Loading…
Add table
Reference in a new issue