Changeset 4571 for exist/trunk


Ignore:
Timestamp:
09/12/08 11:30:15 (11 years ago)
Author:
cbyrom
Message:

Various fixes to get interface to CDML/CSML code library working correctly - and to handle any output errors. NB, adjust CSML lib to
raise exception instead of just exiting on error.

Location:
exist/trunk/python/ndgUtils
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • exist/trunk/python/ndgUtils/lib/granulite.py

    r4562 r4571  
    118118 
    119119        self.useCSMLID = useCSMLID 
    120         self.timeAxis = timeAxis 
    121         self.datasetID = datasetID 
     120        self._cdmlTimeAxis = timeAxis 
     121        self._datasetID = datasetID 
    122122             
    123123        logging.info("Granulite data model set up") 
     
    237237                self._csmlFileName = granulite_data[self.CSML_SECTION][0] 
    238238 
    239         if self.CDML_SECTION in granulite_data: 
    240             if self.CSML_SECTION in granulite_data: 
    241                 raise ValueError("Cannot specify both CDML and CSML file in granulite config file" + \ 
    242                                  "\nNB, CSML file is generated from the specified CDML file") 
    243              
    244             data = utilities.getTripleData(granulite_data[self.CDML_SECTION][0]) 
    245             self._cdmlFileName = data[0] 
    246             self._datasetID = data[1] 
    247             self._cdmlTimeAxis = data[2] 
     239        if not self._cdmlFileName: 
     240            if self.CDML_SECTION in granulite_data: 
     241                if self._csmlFileName: 
     242                    raise ValueError("Cannot specify both CDML and CSML file in granulite config file" + \ 
     243                                     "\nNB, CSML file is generated from the specified CDML file") 
     244             
     245                data = utilities.getTripleData(granulite_data[self.CDML_SECTION][0]) 
     246                self._cdmlFileName = data[0] 
     247                self._datasetID = data[1] 
     248                self._cdmlTimeAxis = data[2] 
    248249             
    249250        if self.DATA_ENTITY_SECTION in granulite_data: 
     
    387388        logging.info("Adding CDML file to eXist") 
    388389        self._eXist.createOrUpdateEXistFile(self._cdmlContent, \ 
    389                                             eXistConnector.NDG_A_COLLECTION_PATH,\ 
     390                                            eXistConnector.NDG_A_COLLECTION_PATH + \ 
     391                                            self._atom.ME.providerID + '/',\ 
    390392                                            fileName) 
    391393        self._atom.cdmlFile = eXistConnector.NDG_A_COLLECTION_PATH + fileName 
    392394         
    393         import pdb 
    394         pdb.set_trace() 
    395          
    396395        # create a local copy of the CDML file - NB, this is required if running 
    397396        # from web app 
    398         fn = os.path.basename(fileName + str(datetime.datetime.today().microsecond)) 
    399         open(fn, 'wb').write(self._cdmlContent) 
     397        fn = os.path.basename(str(datetime.datetime.today().microsecond) + fileName) 
     398        cdmlFile = open(fn, 'wb') 
     399        cdmlFile.write(self._cdmlContent) 
     400        cdmlFile.close() 
    400401        message = 'The file "' + fn + '" was uploaded successfully' 
    401402         
    402403        logging.info("Create CSML file from the CDML file - NB, this will be stored in eXist too " + \ 
    403404                     "and will be used to extract dataset information from") 
    404         self._csmlFileName = utilities.createCSMLFile(self._cdmlFileName, self._datasetID, self._cdmlTimeAxis) 
     405        csmlFileName = utilities.createCSMLFile(fn, self._datasetID, self._cdmlTimeAxis) 
     406        os.remove(fn) 
     407         
     408        logging.info("CSML file successfully created - now processing this") 
     409        self.__addCSMLOrCDMLData(csmlFileName, None) 
     410         
     411        # NB, can remove the CSML file now since the contents are read into memory 
     412        os.remove(csmlFileName) 
    405413        logging.info("Finished processing CDML file") 
    406414 
  • exist/trunk/python/ndgUtils/lib/utilities.py

    r4562 r4571  
    227227    CSMLFileName = datasetID + "_csml.xml" 
    228228    logging.debug("Inputs specified: datasetID = %s, timeAxis = %s" %(datasetID, timeAxis)) 
    229     inputVals = ['csmlscan', '-o', CSMLFileName, CDMLFilePath] 
     229    inputVals = ['csmlscan', '-o', CSMLFileName] 
    230230    if datasetID: 
    231231        inputVals.extend(['-i', datasetID]) 
    232232    if timeAxis: 
    233233        inputVals.extend(['-t', timeAxis]) 
     234     
     235    inputVals.append(CDMLFilePath) 
    234236     
    235237    CsmlScan.main(inputVals) 
     
    264266    # NB, this is a bit of a fudge - there may be a better way to check for 
    265267    # CDML-ness 
    266     if filecontent.find(ndgObject.CDML_DTD) > -1 or \ 
     268    if fileContent.find(ndgObject.CDML_DTD) > -1 or \ 
    267269        (fileContent.find('dataset') > -1 and \ 
    268270        fileContent.find('attr') > -1 and \ 
  • exist/trunk/python/ndgUtils/models/Atom.py

    r4564 r4571  
    10911091        bbox1 = csmlDoc.getBoundingBox() 
    10921092        bbox2 = csmlDoc.getCSMLBoundingBox() 
    1093         time = bbox2.getTimeLimits() 
     1093 
     1094        time = None 
     1095        if bbox2: 
     1096            time = bbox2.getTimeLimits() 
    10941097     
    10951098        # now check for other parameters to add to granule 
Note: See TracChangeset for help on using the changeset viewer.