awips2/deltaScripts/14.4.1/DR3685/preserveAreaDictionary.py
Ron Anderson 82aa416c48 Omaha #3997 Create delta script to preserve the site's current AreaDictionary.py file
Change-Id: Id38826c171ed6d87fd8b677c53df7e2a6b49254c

Former-commit-id: 9da286a579c582db47d63aba83552f5361d819e0
2015-01-13 14:32:50 -06:00

42 lines
1.6 KiB
Python
Executable file

#!/usr/bin/env python
# This script will preserve the site's current configured AreaDictionary.py file as
# a site level file if one does not already exist.
AREA_DICTIONARY_PATH = "/awips2/edex/data/utility/cave_static/configured/*/gfe/userPython/textUtilities/regular/AreaDictionary.py"
import glob
import os
import shutil
import traceback
def main():
# for each configured AreaDictionary.py file
for configFile in glob.glob(AREA_DICTIONARY_PATH):
siteFile = configFile.replace("cave_static/configured", "cave_static/site")
# if site file does not exist
if not os.path.exists(siteFile):
# create site directory if necessary
try:
os.makedirs(os.path.dirname(siteFile))
except OSError as e:
import errno
if e.errno != errno.EEXIST:
print "Error copying", configFile, "\n to", siteFile, \
"\nPlease manually copy this file before starting EDEX"
traceback.print_exc()
continue
# copy configured file to site.
print "Preserving", siteFile
try:
shutil.copy(configFile, siteFile)
except:
print "Error copying", configFile, "\n to", siteFile, \
"\nPlease manually copy this file before starting EDEX"
traceback.print_exc()
else:
print "Skipping ", configFile, "\n ", siteFile, "exists"
if __name__ == "__main__":
main()