def createNewProjectInfo( self, a_currentHost ):
    '''
    create a new projectInfo.xml file
    '''
    #If the projectInfo.xml file is already been created, return
    if os.path.exists( '.scientificProjectManager/projectInfo.xml' ):
      print "The .scientificProjectManager/projectInfo.xml is already been created!"
      return

    #Create the XML tree of the project information
    projectInfo      = ET.Element('projectInfo')
    hostInfo         = ET.SubElement( projectInfo, 'hostInfo' )
    currentHost      = ET.SubElement( hostInfo, 'currentHost' )
    hostList         = ET.SubElement( hostInfo, 'hostList'    )
    host             = ET.SubElement( hostList, a_currentHost )
    homeAbsPath      = ET.SubElement( host, 'homeAbsPath'     )
   
    currentHost.text = a_currentHost
    homeAbsPath.text = os.path.abspath('.')

    #Save the projectInfo.xml file
    fXml = open('.scientificProjectManager/projectInfo.xml', 'w')
    fXml.write( utilities.getPrettyXmlString( projectInfo ) )
    fXml.close() 
    return
 def saveXMLFile( self, a_xmlElement, a_fOut ):
   '''
   Save an XML element to a file.
   Address of a_fOut should be relative to the project home.
   '''
   with open( self.getAbsAddr(a_fOut), 'w' ) as fOut:
     fOut.write( utilities.getPrettyXmlString( a_xmlElement ) )  
   return
  def createNewProjectGraph( self ):
    '''
    create a new projectGraph.xml file
    '''
    #If the projectGraph.xml file is already been created, return
    if os.path.exists( '.scientificProjectManager/projectGraph.xml' ):
      print "The .scientificProjectManager/projectGraph.xml is already been created!"
      return

    #Create the XML tree of the project graph
    projectGraph = ET.Element('projectGraph')
    nodes        = ET.SubElement( projectGraph, 'nodes' )
    edges        = ET.SubElement( projectGraph, 'edges' )

    #Save the projectGraph.xml file
    fXml = open('.scientificProjectManager/projectGraph.xml', 'w')
    fXml.write( utilities.getPrettyXmlString( projectGraph ) )
    fXml.close() 
    return
  def createNewProjectLog( self, a_currentHost ):
    '''
    create a new projectLog.xml file
    '''
    #If the projectLog.xml file is already been created, return
    if os.path.exists( '.scientificProjectManager/projectLog.xml' ):
      print "The .scientificProjectManager/projectLog.xml is already been created!"
      return

    #Create the XML tree of the project log
    projectLog = ET.Element('projectLog')
    record     = ET.SubElement( projectLog, 'record' )
    timeE      = ET.SubElement( record, 'time'       )
    host       = ET.SubElement( record, 'host'       )
    event      = ET.SubElement( record, 'event'      )
    timeE.text = time.strftime('%Y_%m_%d_%H_%M_%S')
    host.text  = a_currentHost
    event.text = "Create metadata"

    #Save the projectLog.xml file
    fXml = open('.scientificProjectManager/projectLog.xml', 'w')
    fXml.write( utilities.getPrettyXmlString( projectLog ) )
    fXml.close() 
    return
 def saveToFile( self, a_fileName ):
   xmlFile = open( a_fileName, 'w' )
   xmlFile.write( utilities.getPrettyXmlString( self.xmlRoot ) )
   xmlFile.close()
   return