changeset 6:f0417a01690a

error handling if file renaming not possible
author dwinter
date Fri, 02 Nov 2012 09:06:44 +0100
parents 3ebe37d81071
children 78dd28ade713
files addDriToIndexMeta.py
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/addDriToIndexMeta.py	Fri Nov 02 09:01:35 2012 +0100
+++ b/addDriToIndexMeta.py	Fri Nov 02 09:06:44 2012 +0100
@@ -10,6 +10,7 @@
 
 from os.path import join, getsize
 
+errorFile = file("/tmp/addDRIErrors.txt","w")
 
 def addPURL(fl,purl,test=False):
     tree = etree.parse(fl)
@@ -31,14 +32,17 @@
     print etree.tostring(tree, pretty_print=True)
     
     if not test:
-        os.rename(fl, fl+"_mpiwg_dri")
-        out = etree.tostring(tree, encoding="UTF-8",xml_declaration=False)
-        fo = file(fl,"w")
-        fo.write(out)
-        fo.close
+        try:
+            os.rename(fl, fl+"_mpiwg_dri")
+            out = etree.tostring(tree, encoding="UTF-8",xml_declaration=False)
+            fo = file(fl,"w")
+            fo.write(out)
+            fo.close
+        except:
+            errorFile.write(fl+"\n")
     return True
     
-def addDriToIndexMeta(path,delpath="",replacepath="", update=False,test=False):
+def addDriToIndexMeta(path,delpath="",replacepath="",test=False):