Mercurial > hg > documentViewer
comparison documentViewer.py @ 37:ead830ce45d6 Root_roc_1
better error messages
author | casties |
---|---|
date | Wed, 12 Apr 2006 20:53:00 +0200 |
parents | 2d9261aea8f3 |
children | 025d3b6cba51 |
comparison
equal
deleted
inserted
replaced
36:0bf5aac0ff41 | 37:ead830ce45d6 |
---|---|
175 dom = NonvalidatingReader.parseUri(imageUrl) | 175 dom = NonvalidatingReader.parseUri(imageUrl) |
176 break | 176 break |
177 except: | 177 except: |
178 zLOG.LOG("documentViewer (getdirinfofromdigilib)", zLOG.ERROR, "error reading %s (try %d)"%(imageUrl,cnt)) | 178 zLOG.LOG("documentViewer (getdirinfofromdigilib)", zLOG.ERROR, "error reading %s (try %d)"%(imageUrl,cnt)) |
179 else: | 179 else: |
180 raise IOError("Unable to get dirinfo from %s"%(imageUrl)) | 180 raise IOError("Unable to get dir-info from %s"%(imageUrl)) |
181 | 181 |
182 params=dom.xpath("//dir/size") | 182 sizes=dom.xpath("//dir/size") |
183 zLOG.LOG("documentViewer (getparamfromdigilib)", zLOG.INFO, "dirInfo:size"%params) | 183 zLOG.LOG("documentViewer (getparamfromdigilib)", zLOG.INFO, "dirInfo:size"%sizes) |
184 | 184 |
185 if params: | 185 if sizes: |
186 docinfo['numPages'] = int(getTextFromNode(params[0])) | 186 docinfo['numPages'] = int(getTextFromNode(sizes[0])) |
187 else: | 187 else: |
188 docinfo['numPages'] = 0 | 188 docinfo['numPages'] = 0 |
189 | 189 |
190 return docinfo | 190 return docinfo |
191 | 191 |
197 # real URL | 197 # real URL |
198 try: | 198 try: |
199 dom = NonvalidatingReader.parseUri(url) | 199 dom = NonvalidatingReader.parseUri(url) |
200 except: | 200 except: |
201 zLOG.LOG("documentViewer (getIndexMata)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2]) | 201 zLOG.LOG("documentViewer (getIndexMata)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2]) |
202 raise IOError("Unable to get info from %s"%(url)) | 202 raise IOError("Unable to read index.meta from %s"%(url)) |
203 else: | 203 else: |
204 # online path | 204 # online path |
205 server=self.digilibBaseUrl+"/servlet/Texter?fn=" | 205 server=self.digilibBaseUrl+"/servlet/Texter?fn=" |
206 metaUrl=server+url | 206 metaUrl=server+url |
207 if not metaUrl.endswith("index.meta"): | 207 if not metaUrl.endswith("index.meta"): |
208 metaUrl += "/index.meta" | 208 metaUrl += "/index.meta" |
209 try: | 209 try: |
210 dom = NonvalidatingReader.parseUri(metaUrl) | 210 dom = NonvalidatingReader.parseUri(metaUrl) |
211 except: | 211 except: |
212 zLOG.LOG("documentViewer (getIndexMata)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2]) | 212 zLOG.LOG("documentViewer (getIndexMata)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2]) |
213 raise IOError("Unable to get info from %s"%(url)) | 213 raise IOError("Unable to read index meta from %s"%(url)) |
214 | 214 |
215 return dom | 215 return dom |
216 | 216 |
217 | 217 |
218 def getAuthinfoFromIndexMeta(self,path,docinfo=None,dom=None): | 218 def getAuthinfoFromIndexMeta(self,path,docinfo=None,dom=None): |
219 """gets authorization info from the index.meta file at path or given by dom""" | 219 """gets authorization info from the index.meta file at path or given by dom""" |
220 zLOG.LOG("documentViewer (getbibinfofromindexmeta)", zLOG.INFO,"path: %s"%(path)) | 220 zLOG.LOG("documentViewer (getauthinfofromindexmeta)", zLOG.INFO,"path: %s"%(path)) |
221 | 221 |
222 access = None | 222 access = None |
223 | 223 |
224 if docinfo is None: | 224 if docinfo is None: |
225 docinfo = {} | 225 docinfo = {} |
291 | 291 |
292 imageDirs=dom.xpath("//texttool/image") | 292 imageDirs=dom.xpath("//texttool/image") |
293 if imageDirs and (len(imageDirs)>0): | 293 if imageDirs and (len(imageDirs)>0): |
294 imageDir=getTextFromNode(imageDirs[0]) | 294 imageDir=getTextFromNode(imageDirs[0]) |
295 else: | 295 else: |
296 imageDir=None | 296 # we balk with no image tag |
297 raise IOError("No text-tool info in %s"%(url)) | |
297 | 298 |
298 if imageDir and archivePath: | 299 if imageDir and archivePath: |
299 #print "image: ", imageDir, " archivepath: ", archivePath | 300 #print "image: ", imageDir, " archivepath: ", archivePath |
300 imageDir=os.path.join(archivePath,imageDir) | 301 imageDir=os.path.join(archivePath,imageDir) |
301 imageDir=imageDir.replace("/mpiwg/online",'') | 302 imageDir=imageDir.replace("/mpiwg/online",'') |
350 docinfo = self.getDocinfoFromTextTool(url, docinfo=docinfo) | 351 docinfo = self.getDocinfoFromTextTool(url, docinfo=docinfo) |
351 elif mode=="imagepath": | 352 elif mode=="imagepath": |
352 docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo) | 353 docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo) |
353 else: | 354 else: |
354 zLOG.LOG("documentViewer (getdocinfo)", zLOG.ERROR,"unknown mode!") | 355 zLOG.LOG("documentViewer (getdocinfo)", zLOG.ERROR,"unknown mode!") |
356 raise ValueError("Unknown mode %s"%(mode)) | |
357 | |
355 zLOG.LOG("documentViewer (getdocinfo)", zLOG.INFO,"docinfo: %s"%docinfo) | 358 zLOG.LOG("documentViewer (getdocinfo)", zLOG.INFO,"docinfo: %s"%docinfo) |
356 self.REQUEST.SESSION['docinfo'] = docinfo | 359 self.REQUEST.SESSION['docinfo'] = docinfo |
357 return docinfo | 360 return docinfo |
358 | 361 |
359 | 362 |