Ignore:
Timestamp:
26/01/07 20:38:15 (13 years ago)
Author:
selatham
Message:

Plugging in new d2boneoff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI01-discovery/trunk/ingestAutomation/OAIBatch/oai_ingest.py

    r1971 r2067  
    161161                    y=loadET(xml) 
    162162                    d=DIF(xml) 
    163                     print d.entryID 
     163                    #print "ID extracted from the DIF = %s" %d.entryID 
    164164                    if NDG_dataProvider: 
    165165                        new_filename = outdir + "/"+d.entryID.replace(":","__")+".xml" 
     
    168168                else: 
    169169                    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) 
    172171                commandline = "cp "+original_filename+ " " +new_filename 
    173172                #print "Executing : " + commandline 
     
    187186 
    188187#are there any old records hanging around.If so, copy away 
    189 outdir = "./DIF2MOLES" 
    190188try: 
    191     os.stat(outdir) 
     189    os.stat("./DIF2MOLES") 
    192190except: 
    193191    print "No old moles records hanging around" 
     
    198196    if status !=0: 
    199197        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 
     206filenames = os.listdir(outdir) 
     207for 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 
    214232#There should be some records now 
    215233try: 
    216     os.stat(outdir) 
     234    os.stat("./DIF2MOLES") 
    217235except: 
    218236    print "ERROR: couldn't create any minimum moles records for %s" %datacentre 
     
    227245 
    228246#Extract the spatiotemporal info from created moles and put in Postgres db 
    229 SpaceTimeIngestFromMOLES.main(outdir) 
     247SpaceTimeIngestFromMOLES.main("./DIF2MOLES") 
    230248 
    231249#Make copies of discovery and oai/originals and DIF2MOLES areas to backup area for tape backups 
     
    283301 
    284302#remove the DIF2MOLES directory 
    285 commandline = "rmdir ./DIF2MOLES" 
    286 print "Executing : " + commandline 
    287 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) 
    290308 
    291309print "======================================================" 
Note: See TracChangeset for help on using the changeset viewer.