- Timestamp:
- 26/01/07 20:38:15 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI01-discovery/trunk/ingestAutomation/OAIBatch/oai_ingest.py
r1971 r2067 161 161 y=loadET(xml) 162 162 d=DIF(xml) 163 printd.entryID163 #print "ID extracted from the DIF = %s" %d.entryID 164 164 if NDG_dataProvider: 165 165 new_filename = outdir + "/"+d.entryID.replace(":","__")+".xml" … … 168 168 else: 169 169 sys.exit("Doesn't handle anything else but DIF here.") 170 #new_filename = outdir + "/" +datacentre_namespace+ "__"+datacentre_format+ "__"+filename.split('%3A')[-1] 171 print "original file = %s, newfile = %s" %(original_filename, new_filename) 170 #print "original file = %s, newfile = %s" %(original_filename, new_filename) 172 171 commandline = "cp "+original_filename+ " " +new_filename 173 172 #print "Executing : " + commandline … … 187 186 188 187 #are there any old records hanging around.If so, copy away 189 outdir = "./DIF2MOLES"190 188 try: 191 os.stat( outdir)189 os.stat("./DIF2MOLES") 192 190 except: 193 191 print "No old moles records hanging around" … … 198 196 if status !=0: 199 197 sys.exit("Failed at clearing out DIF2MOLES area.") 200 commandline = "rmdir ./DIF2MOLES" 201 print "Executing : " + commandline 202 status = os.system(commandline) 203 if status !=0: 204 sys.exit("Failed at removing DIF2MOLES directory.") 205 206 # Then run the minimum moles creator which will run over all records in the supplied collection 207 # creates a directory ./DIF2MOLES to pass back records with original filename 208 commandline = "java -jar D2B/d2b.jar repositoryID " +datacentre_namespace+" repositoryLocalID "+datacentre+" format "+datacentre_format+" repository xmldb:exist://glue.badc.rl.ac.uk:8080/exist/xmlrpc userpw xxxxxx targetCollection /db/discovery/original/"+datacentre_format+"/"+datacentre_namespace 209 print "Executing command to run d2b.jar" 210 status= os.system(commandline) 211 if status!=0: 212 print "ERROR: couldn't create the minimum moles records" 213 sys.exit 198 #commandline = "rmdir ./DIF2MOLES" 199 #print "Executing : " + commandline 200 #status = os.system(commandline) 201 i#f status !=0: 202 # sys.exit("Failed at removing DIF2MOLES directory.") 203 204 # Then run the minimum moles creator for each discovery record 205 # Put records in ./DIF2MOLES with original filename 206 filenames = os.listdir(outdir) 207 for filename in filenames: 208 if filename.find('.xml') != -1: 209 if datacentre_format == "DIF": 210 original_filename = outdir + "/" + filename 211 from DIF import DIF 212 from ETxmlView import loadET 213 xml=file(original_filename).read() 214 y=loadET(xml) 215 d=DIF(xml) 216 print "ID extracted from the DIF = %s" %d.entryID 217 if NDG_dataProvider: 218 molesLocalID = d.entryID.split(":",2)[2] 219 else: 220 molesLocalID = d.entryID 221 print "molesLocalID is %s" %molesLocalID 222 commandline = "java -jar D2B/d2boneoff.jar repositoryID " +datacentre_namespace+" repositoryLocalID "+datacentre+" format "+ \ 223 datacentre_format+" repository xmldb:exist://glue.badc.rl.ac.uk:8080/exist/xmlrpc userpw xxxxxx targetCollection /db/discovery/original/"+ \ 224 datacentre_format+"/"+datacentre_namespace +" inputRecordID "+d.entryID+ " outputLocalID "+molesLocalID+ " > ./DIF2MOLES/"+filename 225 print "Executing command to run d2boneoff.jar" 226 status= os.system(commandline) 227 if status==10: 228 print "WARNING: couldn't find the record" 229 elif status!=0: 230 print "ERROR: couldn't create the minimum moles records" 231 sys.exit 214 232 #There should be some records now 215 233 try: 216 os.stat( outdir)234 os.stat("./DIF2MOLES") 217 235 except: 218 236 print "ERROR: couldn't create any minimum moles records for %s" %datacentre … … 227 245 228 246 #Extract the spatiotemporal info from created moles and put in Postgres db 229 SpaceTimeIngestFromMOLES.main( outdir)247 SpaceTimeIngestFromMOLES.main("./DIF2MOLES") 230 248 231 249 #Make copies of discovery and oai/originals and DIF2MOLES areas to backup area for tape backups … … 283 301 284 302 #remove the DIF2MOLES directory 285 commandline = "rmdir ./DIF2MOLES"286 print "Executing : " + commandline287 status = os.system(commandline)288 if status !=0:289 sys.exit("Failed at removing DIF2MOLES directory %s" %harvest_home)303 ##commandline = "rmdir ./DIF2MOLES" 304 #print "Executing : " + commandline 305 #status = os.system(commandline) 306 #if status !=0: 307 # sys.exit("Failed at removing DIF2MOLES directory %s" %harvest_home) 290 308 291 309 print "======================================================"
Note: See TracChangeset
for help on using the changeset viewer.