changeset 7:78dd28ade713

error handling
author dwinter
date Fri, 02 Nov 2012 09:25:11 +0100
parents f0417a01690a
children 733d43b30a82
files addDriToIndexMeta.py manageIndexMetaPURLs.py
diffstat 2 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/addDriToIndexMeta.py	Fri Nov 02 09:06:44 2012 +0100
+++ b/addDriToIndexMeta.py	Fri Nov 02 09:25:11 2012 +0100
@@ -11,10 +11,14 @@
 from os.path import join, getsize
 
 errorFile = file("/tmp/addDRIErrors.txt","w")
+parseErrorFile = file("/tmp/addDRIParseErrors.txt","w")
 
 def addPURL(fl,purl,test=False):
-    tree = etree.parse(fl)
-    
+    try:
+        tree = etree.parse(fl)
+    except:
+        parseErrorFile.write("PARSE ERROR:"+fl+"\n")
+        return False
     dris = tree.xpath("/resource/meta/dri[@type='mpiwg']")
     
     if len(dris)==0: # erzeuge neu
@@ -22,7 +26,7 @@
         newDri.text=purl
         metas=tree.xpath("/resource/meta")
         if len(metas)==0:
-            print "no resource/meta in %s"%fl
+            parseErrorFile.write("no resource/meta: %s \n"%fl)
             return False
         else:
             metas[0].append(newDri)
@@ -66,4 +70,4 @@
                 dirs.remove(dir)
 
 if __name__ == '__main__':
-     addDriToIndexMeta("/mpiwg/online/permanent/annalen",delpath="/mpiwg/online")
\ No newline at end of file
+     addDriToIndexMeta("/mpiwg/online/",delpath="/mpiwg/online",test=False)
--- a/manageIndexMetaPURLs.py	Fri Nov 02 09:06:44 2012 +0100
+++ b/manageIndexMetaPURLs.py	Fri Nov 02 09:25:11 2012 +0100
@@ -38,7 +38,7 @@
     
   
     def __init__(self):
-        self.purlDB = web.database(dbn="postgres", db="purlDB",user="purlUSER",password="3333", host="localhost")
+        self.purlDB = web.database(dbn="postgres", db="purlDB",user="purlUSER",password="p*lWa55eR", host="localhost")