regeneratejava.py 1.67 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
#!/usr/local/apps/bin/python
import sys, os 

#
# Get the output of a command as a tuple of strings.
#
def GetFilenames(command):
    p = os.popen(command)
    files = p.readlines()
    p.close()
    return files

#
# Execute a command. It's wrapped for debugging.
#
def systemCommand(command):
    print command
    return os.system(command)

###############################################################################
#
# Purpose: This program regenerates all of the java state objects in this 
#          directory by first finding the XML files and then calling xml2java.
#
# Programmer: Kathleen Biagas 
# Date:       June 26, 2013
#
# Modifications:
#
###############################################################################

def main(exeDir):
    # Get the names of the XML files in the common/state directory.
    files = GetFilenames("ls ../common/state/*.xml")

    # regenerate the java files
    for f in files:
        command = "%s/xml2java -clobber %s" % (exeDir, f)
        systemCommand(command)

    # Get the names of the XML files in the avt/DBAtts/MetaData directory.
    files = GetFilenames("ls ../avt/DBAtts/MetaData/*.xml")

    # regenerate the java files
    for f in files:
        command = "%s/xml2java -clobber %s" % (exeDir, f)
        systemCommand(command)

    # Get the names of the XML files in the viewer/rpc directory.
    files = GetFilenames("ls ../viewer/rpc/*.xml")

    # regenerate the java files
    for f in files:
        command = "%s/xml2java -clobber %s" % (exeDir, f)
        systemCommand(command)

    return 0

#
# Call the main function
#
if len(sys.argv) > 1:
    main(sys.argv[1])
else:
    print "usage: regeneratejava.py /path/to/xml2java"