Esempio n. 1
0
def write_variables(program_name, variable_map, file_path, append=False):
    """
    Write the dictionary of variables to the specified file.
    :param program_name: name of tool that invoked the method which will be written to the variable properties file
    :param variable_map: the dictionary of variables
    :param file_path: the file to which to write the properties
    :param append: defaults to False. Append properties to the end of file
    :raises VariableException if an error occurs while storing the variables in the file
    """
    _method_name = 'write_variables'
    _logger.entering(program_name, file_path, append, class_name=_class_name, method_name=_method_name)
    props = Properties()
    for key in variable_map:
        value = variable_map[key]
        props.setProperty(key, value)

    comment = exception_helper.get_message('WLSDPLY-01731', program_name)
    output_stream = None
    try:
        output_stream = FileOutputStream(File(file_path), Boolean(append))
        props.store(output_stream, comment)
        output_stream.close()
    except IOException, ioe:
        ex = exception_helper.create_variable_exception('WLSDPLY-20007', file_path,
                                                        ioe.getLocalizedMessage(), error=ioe)
        _logger.throwing(ex, class_name=_class_name, method_name=_method_name)
        if output_stream is not None:
            output_stream.close()
        raise ex
Esempio n. 2
0
 def save_versions(self):
     print "save versions"
     versionsProperties = Properties()
     outFile = FileOutputStream(self.versionsFileName)
     versionsProperties.setProperty("script", self.app.SCRIPTVERSION)
     versionsProperties.setProperty("tools", self.app.TOOLSVERSION)
     versionsProperties.store(outFile, None)
     outFile.close()
Esempio n. 3
0
 def save_versions(self):
     print "save versions"
     versionsProperties = Properties()
     outFile = FileOutputStream(self.versionsFileName)
     versionsProperties.setProperty("script", self.app.SCRIPTVERSION)
     versionsProperties.setProperty("tools", self.app.TOOLSVERSION)
     versionsProperties.store(outFile, None)
     outFile.close()
Esempio n. 4
0
def savePreviousArguments(managedServerName):
    from java.io import File
    from java.io import FileOutputStream
    from java.util import Properties
    from java.util import Date
    from java.text import SimpleDateFormat

    import string
    startToEdit()
    # parameter on the wsdl ant task call
    fileLocation = sys.argv[1].replace("\\", "/")
    print "The backup file location is"
    print fileLocation
    try:
        dateFormat = SimpleDateFormat('_d_MMM_yyyy_HH_mm_ss')
        date = Date()
        formattedDate = dateFormat.format(date)
        print formattedDate
    except:
        print "The date cannot be created/formatted"

    try:
        propsFile = File(fileLocation + managedServerName + formattedDate +
                         "_config.bkp")
        print propsFile.exists()
        if (propsFile.exists() == 0):
            propsFile.createNewFile()
    except:
        print "The file cannot be created on:"
        print propsFile.getAbsoluteFile()
        dumpStack()

    previousProperties = Properties()
    print '===> Saving the  previous arguments - ' + managedServerName
    cd('/Servers/' + managedServerName)
    print "Getting the Classpath"
    classPath = cmo.getServerStart().getClassPath()
    print classPath
    if classPath == None:
        classPath = ""
    previousProperties.setProperty("classPath", classPath)
    print "Saving Arguments to file"
    previousProperties.store(FileOutputStream(propsFile), None)
    print '===> Saved arguments! Please verify the file on:' + fileLocation + "in" + managedServerName
def savePreviousArguments(managedServerName):
    from java.io import File
    from java.io import FileOutputStream
    from java.util import Properties
    from java.util import Date
    from java.text import SimpleDateFormat
    
    import string
    startToEdit()
    # parameter on the wsdl ant task call
    fileLocation = sys.argv[1].replace("\\","/")
    print "The backup file location is"
    print fileLocation
    try:
        dateFormat = SimpleDateFormat('_d_MMM_yyyy_HH_mm_ss')
        date = Date()
        formattedDate = dateFormat.format(date)
        print formattedDate
    except:
        print "The date cannot be created/formatted"
        
    try:    
        propsFile = File(fileLocation+ managedServerName + formattedDate+"_config.bkp");
        print propsFile.exists()
        if(propsFile.exists() == 0):
            propsFile.createNewFile()
    except:
        print "The file cannot be created on:"
        print propsFile.getAbsoluteFile()
        dumpStack()     
        
    previousProperties = Properties()
    print '===> Saving the  previous arguments - ' + managedServerName
    cd('/Servers/'+managedServerName)
    print "Getting the VMArgs"
    vmArgs = cmo.getServerStart().getArguments()
    print vmArgs
    if vmArgs == None:
        vmArgs = ""
    previousProperties.setProperty("vmArgs", vmArgs)
    print "Saving Arguments to file"
    previousProperties.store(FileOutputStream(propsFile),None)
    print '===> Saved arguments! Please verify the file on:'+ fileLocation + "in" + managedServerName