diff harvestToPurl.py @ 4:107f13ca333b

try except added
author dwinter
date Thu, 01 Nov 2012 17:08:10 +0100
parents caeede0c9464
children 1b2d74f94ca8
line wrap: on
line diff
--- a/harvestToPurl.py	Thu Nov 01 15:52:14 2012 +0100
+++ b/harvestToPurl.py	Thu Nov 01 17:08:10 2012 +0100
@@ -31,14 +31,17 @@
                 fl=re.sub("^"+delpath,replacepath,fl) #loesche den teil vom path der mir delpath beginnt
                 
                 val,purl = md.register(fl, True,  user=user,imagePath=imagePath,update=update)
-                if val==manageIndexMetaPURLs.ALREADY_EXISTS:
-                    print "found %s -> %s"%(fl,purl)
+                try:
+                    if val==manageIndexMetaPURLs.ALREADY_EXISTS:
+                        print "found %s -> %s"%(fl,purl)
                 
-                elif val==manageIndexMetaPURLs.UPDATED:
-                    print "updated %s -> %s"%(fl,purl)
-                else:
-                    print "added %s -> %s"%(fl,purl)
-                    
+                    elif val==manageIndexMetaPURLs.UPDATED:
+                        print "updated %s -> %s"%(fl,purl)
+                    else:
+                        print "added %s -> %s"%(fl,purl)
+                except:
+                    print "cannot print: %s"%purl
+                     
         if 'pageimg' in dirs:
             dirs.remove('pageimg')  # don't visit pageimf
         for dir in dirs:
@@ -47,11 +50,19 @@
             if  dir.startswith("."):
                 dirs.remove(dir)
 
+            if  dir.startswith(":"):
+                dirs.remove(dir)
+
 
 # erzeugt einen imagepath wenn kein texttooltag existiert
 def createImagePath(path,root):
-    tree= etree.parse(path)
-    
+    print "parsing: %s"%path
+    try:
+        tree= etree.parse(path)
+    except:
+        print "cannot parse %s"%path
+        return ""
+
     #teste ob texttool tag, dann kein imagePath
     tt =tree.xpath('//texttool')
     if len(tt)>0:
@@ -96,4 +107,4 @@
         
     harvestIndexMeta(path,user,delpath=delpath,replacepath=replacepath,update=True)
     
-    
\ No newline at end of file
+