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