1: """ TO DO generell falls noch ein File, das nicht index.meta -> archivierung ausgeben """
2: from types import *
3: import urllib
4: import os
5: import sys
6: import re
7: from AccessControl import ClassSecurityInfo
8: from AccessControl.Role import RoleManager
9: from Acquisition import Implicit
10: from Globals import Persistent
11: from time import strptime
12: from time import strftime
13: import time
14: import os.path
15: import dircache
16: import xml.dom.minidom
17: from Products.PageTemplates.PageTemplateFile import PageTemplateFile
18: from Products.PageTemplates.PageTemplate import PageTemplate
19: import tempfile
20: tempfile.tempdir="/var/tmp/archiver"
21:
22: exclusion=[".HSResource","lost+found","Network Trash Folder","TheFindByContentFolder","TheVolumeSettingsFolder"]
23: class fsentry(Implicit, Persistent, RoleManager):
24: """File entry class"""
25: path = ""
26: user = ""
27: month = ""
28: date =""
29: time = ""
30:
31: security=ClassSecurityInfo()
32: def __init__(self,extpath):
33: """initialize class"""
34: extpath=os.path.abspath(re.search(r"(.*)\n",extpath).group(1))
35: self.all=extpath
36: self.path=extpath
37: self.user=""
38: self.mtime=os.path.getmtime(extpath)
39:
40:
41: security.declarePublic('getPath')
42: def getPath(self):
43: """Ausgabe von path"""
44: return self.path
45:
46: security.declarePublic('getUser')
47: def getUser(self):
48: """Ausgabe von user"""
49: return self.user
50:
51: security.declarePublic('getDate')
52: def getDate(self):
53: """Ausgabe von Date"""
54: return strftime("%Y%m%d%H%M",time.gmtime(self.mtime))
55:
56: security.declarePublic('getDate')
57: def getID(self):
58: """Ausgabe einer eindeutigen Sortierbaren ID"""
59: return self.getDate()+self.getPath()
60:
61: security.declarePublic('getTime')
62: def getTime(self):
63: """Ausgabe von path"""
64: return self.time
65: security.declarePublic('getAll')
66: def getAll(self):
67: """Ausgabe von path"""
68: return self.all
69:
70: class filesystem(Implicit, Persistent, RoleManager):
71: """store filesystem"""
72: node={}
73: hasindex={}
74: security=ClassSecurityInfo()
75:
76: def getfs(self,start):
77: """load filessystem"""
78: f = os.popen("find "+ start+" -name '*' ","r")
79: lines = f.readlines()
80:
81: return lines
82:
83: def loadfs(self,start):
84: """analyse filesystem"""
85: for line in self.getfs(start):
86:
87: g=re.search(r"(.*/)(.*)\n",line)
88: if not g==None:
89: path=g.group(1)
90: file=g.group(2)
91: if self.node.has_key(path):
92: elements=self.node[path]
93: elements.append(file)
94: self.node[path]=elements
95: else:
96: self.node[path]=[file]
97: if (file=="index.meta") | (file=="meta"):
98: self.hasindex[path]="1"
99:
100: def __init__(self,start,reload=0):
101: if reload==1:
102: self.node={}
103: self.hasindex={}
104: self.loadfs(start)
105:
106:
107: security.declarePublic('getNode')
108: def getNode(self):
109: return self.node
110:
111: security.declarePublic('getKeys')
112: def getKeys(self):
113: return self.node.keys()
114:
115: security.declarePublic('clearnode')
116: def clearnode(self):
117: self.node={}
118: return 0
119:
120: security.declarePublic('hasIndex')
121: def hasIndex(self,path):
122:
123: return self.hasindex.has_key(path)
124:
125:
126: def onlyIndex_old(self):
127: """return only files with archive material"""
128: j={}
129: for k in self.node:
130: if self.hasindex.has_key(k):
131: if len(self.node[k])>1:
132: if (len(self.node[k])==2) & ('meta' not in self.node[k]):
133: j[k]=self.node[k]
134: elif (len(self.node[k])==2) & ('meta' in self.node[k]):
135: """ nothing """
136: else:
137: j[k]=self.node[k]
138: return j
139:
140: def archive_the_path(self,path):
141: """parse indexmeta and return digilib path"""
142: try:
143: #f = os.popen("cat "+path+"/index.meta","r")
144: f =file(path+"/index.meta","r")
145:
146: lines = f.read()
147:
148: try:
149: dom = xml.dom.minidom.parseString(lines)
150: if getText(dom.getElementsByTagName("content-type")[0].childNodes)=="folder":
151: """folder nicht archivieren"""
152: return 0
153: else:
154: archive_storage_date=getText(dom.getElementsByTagName("archive-storage-date")[0].childNodes)
155:
156: if archive_storage_date=="":
157:
158: """leer also archivieren"""
159: return 1
160: else:
161: """nicht archivieren"""
162: return 0
163: except:
164: """kein tag also archivieren"""
165: return 1
166: except:
167: """kein index.meta also nicht archivieren"""
168: return 0
169:
170: security.declarePublic('onlyIndex')
171: def onlyIndex(self):
172: """return only files with archive material (archive-storage-date not set)"""
173: j={}
174:
175: for k in self.node:
176: if self.archive_the_path(k):
177: j[k]=self.node[k]
178: return j
179: security.declarePublic('getImageDirs')
180: def getImageDirs(self,dom,path):
181: dirs=dom.getElementsByTagName("dir")
182: dirback=[]
183: for dir in dirs:
184: temp=getText(dir.getElementsByTagName("name")[0].childNodes)
185: temp2=re.search(r"(.*)/mpiwg/online/(.*)",path+"/"+temp)
186: if not temp2==None:
187: try:
188: dirback.append(temp2.group(2))
189: except:
190: """nothing"""
191: else:
192: dirback.append(temp)
193: return dirback
194:
195:
196:
197:
198: security.declarePublic('digilib')
199: def digilib(self, path):
200: """check if folder is a container for digilib files"""
201: if self.hasindex.has_key(path+"/"):
202: return(self.parseIndexMeta(path))
203: else:
204: return "NO"
205:
206:
207:
208:
209: security.declarePublic('isdigilib')
210: def isdigilib(self, path):
211: """return number of possible image directories usefull for digilib"""
212: if self.hasindex.has_key(path+"/"):
213: return(len(self.parseIndexMeta(path)))
214: else:
215: return 0
216:
217: security.declarePublic('parseIndexMeta')
218: def parseIndexMeta(self,k):
219: """parse indexmeta and return digilib path"""
220: f = os.popen("cat "+k+"/index.meta","r")
221: lines = f.read()
222:
223: try:
224: dom = xml.dom.minidom.parseString(lines)
225: content_type=getText(dom.getElementsByTagName("content-type")[0].childNodes)
226: if (content_type=="scanned-document") or (content_type=="scanned document"):
227: dirs=self.getImageDirs(dom,k)
228:
229: return dirs
230: except:
231: return []
232:
233:
234: class filesystem2(Implicit, Persistent, RoleManager):
235: """store filesystem"""
236: node={}
237: hasindex={}
238: security=ClassSecurityInfo()
239:
240: def getfs(self,start):
241: """load filessystem"""
242: f = os.popen("find "+ start+" -name '*' ","r")
243: lines = f.readlines()
244:
245: return lines
246:
247: def loadfs(self,start):
248: """analyse filesystem"""
249: for line in self.getfs(start):
250:
251: g=re.search(r"(.*/)(.*)\n",line)
252: if not g==None:
253: try:
254: path=g.group(1)
255: file=g.group(2)
256: except:
257: """nothing"""
258: if self.node.has_key(path):
259: elements=self.node[path]
260: elements.append(file)
261: self.node[path]=elements
262: else:
263: self.node[path]=[file]
264: if (file=="index.meta") | (file=="meta"):
265: self.hasindex[path]="1"
266:
267: def __init__(self,start,reload=0):
268: """nothing"""
269:
270: security.declarePublic('getImageDirs')
271: def getImageDirs(self,dom,path):
272: dirs=dom.getElementsByTagName("dir")
273: dirback=[]
274: for dir in dirs:
275: temp=getText(dir.getElementsByTagName("name")[0].childNodes)
276: temp2=re.search(r"(.*)/mpiwg/online/(.*)",path+"/"+temp)
277: if not temp2==None:
278: try:
279: dirback.append(temp2.group(2))
280: except:
281: """nothing"""
282: else:
283: dirback.append(temp)
284: return dirback
285:
286:
287: security.declarePublic('digilib')
288: def digilib(self, path):
289: """check if folder is a container for digilib files"""
290: if os.path.exists(path+"/index.meta"):
291: return(self.parseIndexMeta(path))
292: else:
293: return "NO"
294:
295: security.declarePublic('isdigilib')
296: def isdigilib(self, path):
297: if os.path.exists(path+"/index.meta"):
298: return(len(self.parseIndexMeta(path)))
299: else:
300: return 0
301: security.declarePublic('parseIndexMeta')
302: def parseIndexMeta(self,k):
303: """parse indexmeta and return digilib path"""
304: f = os.popen("cat "+k+"/index.meta","r")
305: lines = f.read()
306:
307: try:
308: dom = xml.dom.minidom.parseString(lines)
309: content_type=getText(dom.getElementsByTagName("content-type")[0].childNodes)
310: if content_type=="scanned-document":
311: dirs=self.getImageDirs(dom,k)
312:
313: return dirs
314: except:
315: return []
316:
317:
318: class browse(Implicit, Persistent, RoleManager):
319:
320: security=ClassSecurityInfo()
321: tree={}
322: toggledict={}
323:
324: def filterExcluded(self,dir):
325: ret=[]
326: for item in dir:
327: if not item in exclusion:
328: ret.append(item)
329: return ret
330:
331: def __init__(self,startpath):
332: self.tree={}
333: self.tree[startpath]=self.filterExcluded(dircache.listdir(startpath))
334:
335: security.declarePublic('getTree')
336: def getTree(self,path):
337: if self.tree.has_key(path):
338: return self.tree[path]
339: else:
340: self.tree[path]=self.filterExcluded(dircache.listdir(path))
341: return self.tree[path]
342:
343: security.declarePublic('isDirectory')
344: def isDirectory(self,path,file):
345: return os.path.isdir(os.path.abspath(path+"/"+file))
346:
347: security.declarePublic('toggle')
348: def toggle(self,tmppath,file):
349: path=tmppath+"/"+file
350:
351: if self.toggledict.has_key(path):
352: if self.toggledict[path]==0:
353: self.toggledict[path]=1
354:
355: else:
356: self.toggledict[path]=0
357:
358: else:
359: self.toggledict[path]=4
360:
361:
362: security.declarePublic('isToggle')
363: def isToggle(self,tmppath,file):
364: path=tmppath+"/"+file
365:
366: if self.toggledict.has_key(path):
367:
368: return self.toggledict[path]
369: else:
370:
371: return 0
372:
373:
374: def getfs(start):
375: """return filesystem"""
376: f = os.popen("find "+ start+" -name '*'","r")
377: lines = f.readlines()
378: return lines
379:
380: def showall(start):
381: lines = getfs(start)
382: for line in lines:
383: print line
384: return 0
385:
386: def entries(start):
387: """retrun list of entries of a filesystem"""
388: i=0
389: fs=[]
390: lines=getfs(start)
391: for line in lines:
392: try:
393: if os.path.exists(os.path.abspath(re.search(r"(.*)\n",line).group(1))):
394: fs.append(fsentry(line))
395: i=i+1
396: except:
397: """nothing"""
398: return fs
399:
400: def getfilesystem(start,reload=0):
401: """load filesystem"""
402:
403: k=filesystem(start,1)
404: return k
405:
406: def getfilesystem2(start,reload=0):
407: """load filesystem"""
408:
409: k=filesystem2(start,1)
410: return k
411:
412: def tree(start):
413: """get the filetree"""
414: k=browse(start)
415: return k
416:
417: def sort_by_date(fs):
418: """sorts lists of fileentries"""
419: ls=[]
420: dict={}
421: for k in fs:
422: ls.append(k.getID())
423: dict[k.getID()]=k
424: ls.sort()
425: ls.reverse()
426: ret=[]
427: for j in ls:
428: ret.append(dict[j])
429: return ret
430:
431: def path_to_link(path):
432: """generates navigation bar for showfiles"""
433: string=""
434:
435: tmppath=os.path.dirname(path)
436: i=0
437: pathes=[[path, os.path.basename(path)]]
438:
439: while not (len(tmppath)==1):
440:
441: i=i+1
442: if i>20: break
443:
444: pathes.append([tmppath, os.path.basename(tmppath)])
445: tmppath=os.path.dirname(tmppath)
446:
447: while i>=0:
448: string=string+"<a href=showfiles?path="+pathes[i][0]+">"+pathes[i][1]+"</a>/"
449:
450: i=i-1
451: return string
452:
453: def path_to_link_view(path):
454: """generates navigation bar for viewfiles"""
455: string=""
456:
457: tmppath=os.path.dirname(path)
458: i=0
459: pathes=[[path, os.path.basename(path)]]
460:
461: while not (len(tmppath)==1):
462:
463: i=i+1
464: if i>20: break
465:
466: pathes.append([tmppath, os.path.basename(tmppath)])
467: tmppath=os.path.dirname(tmppath)
468:
469: while i>=0:
470: string=string+"<a href=viewfiles?path="+pathes[i][0]+">"+pathes[i][1]+"</a>/"
471:
472: i=i-1
473: return string
474:
475: def path_to_link_store(path):
476: """generates navigation bar for viewfiles"""
477: string=""
478:
479: tmppath=os.path.dirname(path)
480: i=0
481: pathes=[[path, os.path.basename(path)]]
482:
483: while not (len(tmppath)==1):
484:
485: i=i+1
486: if i>20: break
487:
488: pathes.append([tmppath, os.path.basename(tmppath)])
489: tmppath=os.path.dirname(tmppath)
490:
491: while i>=0:
492: string=string+"<a href=storefiles?path="+pathes[i][0]+">"+pathes[i][1]+"</a>/"
493:
494: i=i-1
495: return string
496:
497:
498: class Error(Implicit, Persistent, RoleManager):
499:
500: error=[]
501: security=ClassSecurityInfo()
502: def __init__(self,initerror):
503: self.error=initerror[0:]
504:
505: security.declarePublic('getError')
506: def getError(self):
507: return self.error
508:
509: class metacheck(Implicit, Persistent, RoleManager):
510: lines=[]
511: security=ClassSecurityInfo()
512: def parsearchive(self,str):
513: """parse for error"""
514: retstr=''
515:
516: if not len(str)==0:
517: for line in str:
518: retstr=retstr+line+"<br>"
519: check=re.search(r"(.*):(.*)",line)
520: if check.group(1)=='ABORT':
521: error="error"
522: elif check.group(1)=='DONE':
523: error="ok"
524: else:
525: error="running"
526:
527: return [retstr,error]
528: else:
529: return ['','running']
530: def __init__(self,path):
531: """archive the documents in path"""
532: self.lines=[]
533:
534: if type(path)==StringType:
535: f = os.popen("/usr/local/mpiwg/archive/metacheck "+path,"r")
536: self.lines.append(Error([path,self.parsearchive(f.readlines())]))
537: else:
538: for singlepath in path:
539: f = os.popen("/usr/local/mpiwg/archive/metacheck "+singlepath,"r")
540: self.lines.append(Error([singlepath,self.parsearchive(f.readlines())]))
541: security.declarePublic('messages')
542:
543: def messages(self):
544: return self.lines
545:
546:
547:
548:
549: class archive(Implicit, Persistent, RoleManager):
550: lines=[]
551: security=ClassSecurityInfo()
552: def parsearchive(self,str):
553: """parse for error"""
554: retstr=''
555:
556: if not len(str)==0:
557: for line in str:
558: retstr=retstr+line+"<br>"
559: check=re.search(r"(.*):(.*)",line)
560: if check.group(1)=='ABORT':
561: error="error"
562: elif check.group(1)=='DONE':
563: error="ok"
564: else:
565: error="running"
566:
567: return [retstr,error]
568: else:
569: return ['','running']
570:
571: def __init__(self,path,session):
572: """archive the documents in path"""
573: self.lines=[]
574: self.filenames={}
575: session['archiver']=self
576:
577:
578: if type(path)==StringType:
579: self.filenames[path]=tempfile.mktemp()
580: f = os.popen("/usr/local/mpiwg/archive/archiver "+path+" > "+self.filenames[path]+" &","r")
581: else:
582: for singlepath in path:
583: self.filenames[singlepath]=tempfile.mktemp()
584: f = os.popen("/usr/local/mpiwg/archive/archiver "+singlepath+" > "+self.filenames[singlepath]+" &","r")
585:
586: security.declarePublic('messages')
587: def messages(self):
588: self.lines=[]
589: for path in self.filenames.keys():
590:
591: self.lines.append(Error([path,self.parsearchive(open(self.filenames[path],"r").readlines())]))
592: return self.lines
593:
594:
595: def evalext(str):
596: return eval(str)
597:
598: def storeerror(ret,path,context,i):
599: session=context.REQUEST.SESSION
600: session['error%i'%i]=ret
601: session['path%i'%i]=path
602:
603: return 'error?number=%i'%i
604:
605: def geterror(str,context):
606: session=context.REQUEST.SESSION
607: return session[str]
608:
609: def readfile(path):
610:
611: ret=""
612: f=open(path,'r')
613: for g in f.readlines():
614: ret=ret+g
615: return ret
616:
617: def writefile(self,path,txt,REQUEST):
618: f=open(path,'w')
619: f.write(txt)
620: f.close()
621: rval=self.aq_acquire('archive2')
622: return rval()
623:
624:
625: def metachecker(self,path):
626: """check the metadata the documents in path"""
627: self.REQUEST.SESSION['path']=self.REQUEST['path']
628: return metacheck(path)
629:
630: def archiver(self,path):
631: """archive the documents in path"""
632: tmp=archive(path,self.REQUEST.SESSION)
633: return self.REQUEST.RESPONSE.redirect('archive4')
634:
635: def getText(nodelist):
636:
637: rc = ""
638: for node in nodelist:
639:
640: if node.nodeType == node.TEXT_NODE:
641: rc = rc + node.data
642: return rc
643:
644: def getBib(nodelist):
645: rc= "<table border='0'>"
646: print "HI"
647: for node in nodelist:
648:
649: if node.nodeType == node.ELEMENT_NODE:
650: """nothing"""
651: rc = rc+"<tr><td valign='right'>"+str(node.nodeName)+":</td><td> "+getText(node.childNodes)+"</td></tr>"
652: #print rc
653: return rc+"</table>"
654:
655: def getMetafile(path):
656: """get index.meta"""
657: html=[]
658: if not os.path.exists(path+"/index.meta"):
659:
660: return "NO_METADATA"
661: else:
662: f = os.popen("cat "+path+"/index.meta","r")
663: lines = f.read()
664: dom = xml.dom.minidom.parseString(lines)
665: name=getText(dom.getElementsByTagName("name")[0].childNodes)
666: creator=getText(dom.getElementsByTagName("creator")[0].childNodes)
667: creation_date=getText(dom.getElementsByTagName("archive-creation-date")[0].childNodes)
668: description=getText(dom.getElementsByTagName("description")[0].childNodes)
669: try:
670: type=getText(dom.getElementsByTagName("content-type")[0].childNodes)
671: except:
672: type=""
673: if type=="scanned document":
674: html="<h3>Document: "+name+"</h3>"
675: elif type=="folder":
676: html="<h3>Folder: "+name+"</h3>"
677: else:
678: html="<h3>Document: "+name+"</h3>"
679:
680: html=html+"<p><i>created by: "+creator+" at: "+creation_date+"</i></p>"
681: html=html+"<h4>Description</h4><p>"+description+"</p>"
682: try:
683: bib = dom.getElementsByTagName("meta")[0].getElementsByTagName("bib")[0]
684: if bib.attributes.has_key('type'):
685: html=html+"<h4>Info ("+bib.attributes['type'].value+")</h4>"
686: else:
687: html=html+"<h4>Info</h4>"
688: html=html+getBib(bib.childNodes)
689: print html
690: except:
691: """none"""
692:
693: # html=html.encode('utf-8','replace')+getBib(bib.childNodes).encode('utf-8','replace')
694:
695: return html
696:
697: def hasMetafile(path):
698: """get index.meta"""
699: return os.path.exists(path+"/index.meta")
700: #return path
701:
702: def isdigilib2(path):
703: """check if folder is candidate for digilib without metadata"""
704: try:
705: dir=os.listdir(path)
706:
707: imagesuffixes=['.gif','.jpg','.jpeg','.png','.tiff','.tif','.JPG','.TIFF','.TIF']
708: ret=""
709: for a in dir:
710:
711: suffix=os.path.splitext(a)
712:
713: if suffix[1] in imagesuffixes:
714: return 1
715:
716: try:
717: dom=xml.dom.minidom.parse(os.path.split(path)[0]+"/index.meta")
718: for node in dom.getElementsByTagName("dir"):
719:
720: if getText(node.getElementsByTagName("content-type")[0].childNodes)=="images":
721:
722: if getText(node.getElementsByTagName("name")[0].childNodes)==os.path.split(path)[1]:
723: return 1
724: return 0
725: except:
726:
727: return 0
728:
729:
730:
731:
732:
733: except:
734: return 0
735:
736: def isFullText(path,folder_name):
737: """check if foldername in path is full text"""
738:
739: try:
740: dom=xml.dom.minidom.parse(path+"/index.meta")
741: except:
742: """ nothing"""
743: return 0
744: for node in dom.getElementsByTagName("dir"):
745:
746: try:
747: child=getText(node.getElementsByTagName("content-type")[0].childNodes)
748:
749: if child =="fulltext":
750:
751: if getText(node.getElementsByTagName("name")[0].childNodes)==folder_name:
752: return 1
753: except:
754: """nothing"""
755: #print "erro",node
756: #print sys.exc_info()
757: #return 0
758:
759: return 0
760:
761:
762:
763: def isPresentation(path,folder_name):
764: """check if foldername in path is full text"""
765: try:
766: dom=xml.dom.minidom.parse(path+"/index.meta")
767: #print dom.toxml()
768: for dirnode in dom.getElementsByTagName("dir"):
769: try:
770:
771: if getText(dirnode.getElementsByTagName('content-type')[0].childNodes)=='presentation':
772: if getText(dirnode.getElementsByTagName("name")[0].childNodes)==folder_name:
773: return 1
774: except:
775: """nothing"""
776: return 0
777: except:
778:
779: return 0
780:
781:
782:
783:
784:
785: def changeName(path):
786: try:
787: temp2=re.search(r"(.*)/mpiwg/online/(.*)",path)
788: if temp2==None:
789: return "digifiles/"+re.search(r"(.*)/mpiwg/production/docuserver/(.*)",path).group(2)
790: else:
791: return temp2.group(2)
792: except: # hack - im archivbereich keine online darstellung gibt jetzt ein no zurück.
793: return "NO"
794:
795:
796: def test(self):
797: self.i=1
798: #newtemplate=PageTemplateFile('/usr/local/mpiwg/Zope/Extensions/test').__of__(self)
799: self.manage_addProduct['OFSP'].manage_addDTMLMethod('neu','neu')
800: self.getattr('neu').manage_edit('HELLO','neu')
801: return "ok"
802:
803:
804: class ls(Implicit, Persistent, RoleManager):
805: """File entry class"""
806: path = ""
807: user = ""
808: month = ""
809: date =""
810: time = ""
811:
812: security=ClassSecurityInfo()
813:
814: def __init__(self,start):
815: self.outfile=tempfile.mktemp()
816: start['outfile']=self
817: os.popen("ls -R / >"+self.outfile+" &","r")
818:
819:
820: security.declarePublic('read')
821: def read(self):
822: return self.f.read()
823: security.declarePublic('retself')
824: def retself(self):
825: return self
826: security.declarePublic('all')
827: def all(self):
828: ret=""
829: for g in self.f:
830: ret=ret+g
831: return ret
832:
833: security.declarePublic('printOutfile')
834: def printOutfile(self):
835: while not os.path.exists(self.outfile):
836: """nothing"""
837: return open(self.outfile).readlines()
838:
839: class overview(Implicit,Persistent, RoleManager):
840: dir=[]
841: resources={}
842: security=ClassSecurityInfo()
843:
844: def __init__(self,path):
845: dir=os.listdir(path)
846:
847: for file in dir:
848: self.resources[self.getResource(path,file)]=path+"/"+file
849:
850:
851: def getResource(self,path,filename):
852: f=file(path+"/"+filename,'r')
853:
854: for line in f.readlines():
855:
856: if line[0:4]=="INFO":
857: if line[6:14]=="resource":
858: return line
859: return "error"
860:
861: def parsearchive(self,str):
862: """parse for error"""
863: retstr=''
864:
865: if not len(str)==0:
866: for line in str:
867: retstr=retstr+line+"<br>"
868: check=re.search(r"(.*):(.*)",line)
869: if check.group(1)=='ABORT':
870: error="error"
871: elif check.group(1)=='DONE':
872: error="ok"
873: else:
874: error="running"
875:
876: return [retstr,error]
877: else:
878: return ['','running']
879:
880: security.declarePublic('messages')
881: def messages(self):
882: self.lines=[]
883: for name in self.resources.keys():
884: path=self.resources[name]
885:
886: self.lines.append(Error([name,self.parsearchive(open(path,"r").readlines())]))
887: return self.lines
888:
889: security.declarePublic('printResource')
890: def printResource(self):
891: return self.resources
892:
893: def getoverview(path):
894:
895: return overview(path)
896:
897:
898: def ls_test(self):
899: tmp=ls(self.REQUEST.SESSION)
900: return self.REQUEST.RESPONSE.redirect('next')
901:
902: def storeFile(self,something):
903: self.REQUEST.SESSION['something']=something
904: return 1
905:
906: def getFile(self):
907: return self.REQUEST.SESSION['something']
908:
909: def isFolder(self,path):
910: """returns TRUE, wenn path ein Folder ist in den weitere Objekte Folder oder Dokumente gelegt werden dürfen"""
911: return not isScannedDocument(self,path) # vorläufig sind alle Documente die keine scanned documente sind folder.
912:
913: def isScannedDocument(self,path):
914: """returns TRUE, wenn path der Stammordner eines gescannten Documents ist"""
915: try:
916: f = file(path+"/index.meta","r")
917: lines = f.read()
918:
919: try:
920: dom = xml.dom.minidom.parseString(lines)
921: content_type=getText(dom.getElementsByTagName("content-type")[0].childNodes)
922: if (content_type=="scanned-document") or (content_type=="scanned document"):
923: return 1
924: else:
925: return 0
926: except:
927: return 0
928: except:
929: return 0
930:
931: from time import localtime,strftime
932:
933: def date(self):
934: return strftime("%d.%m.%Y",localtime())
935:
936:
937:
938: def EditIndex(self,path):
939: try:
940: dom=xml.dom.minidom.parse(path+"/index.meta")
941: indexmeta=dom.toxml()
942: except:
943: indexmeta=""
944: self.REQUEST.SESSION['indexmeta']=indexmeta
945: self.REQUEST.SESSION['path']=path
946: newtemplate=PageTemplateFile('/usr/local/mpiwg/Zope/Extensions/editindex').__of__(self)
947: return newtemplate()
948:
949: def EditIndex2(self):
950: if not self.REQUEST.has_key('fileupload'):
951: #newtext=urllib.unquote(self.REQUEST['indexmeta'])
952: newtext=self.REQUEST['indexmeta']
953: print newtext
954: else:
955: self.file_name=self.REQUEST['fileupload'].filename
956: #newtext=self.REQUEST.form['fileupload'].read()
957: # HACK DW
958: newtext=self.REQUEST['indexmeta']
959:
960: indexmeta=file(self.REQUEST.SESSION['path']+"/index.meta","w")
961: indexmeta.writelines(newtext)
962: return self.REQUEST.response.redirect("storage/storefiles?path="+self.REQUEST.SESSION['path'])
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>