--- OSAS/OSA_system/OSAS_add.py 2006/07/03 17:40:18 1.48 +++ OSAS/OSA_system/OSAS_add.py 2010/02/15 19:09:00 1.53 @@ -1,7 +1,7 @@ #Neue Version Begin 5.4.2004 -"""Methoden zum hinzufügen von Dokumenten ins Archiv""" +"""Methoden zum hinzufuegen von Dokumenten ins Archiv""" from OSAS_helpers import readArchimedesXML try: import archive @@ -14,7 +14,14 @@ from Products.PageTemplates.PageTemplate from Products.PageTemplates.PageTemplate import PageTemplate import string import urllib -import zLOG +import logging + +#ersetzt logging +def logger(txt,method,txt2): + """logging""" + logging.info(txt+ txt2) + + import xml.dom.minidom from time import localtime,strftime from Globals import package_home @@ -279,7 +286,7 @@ def addPresentation(self,path): self.REQUEST.SESSION['presentationname']="%02d-presentation"%i self.REQUEST.SESSION['path']=path - tmpTxt=""" + tmpTxt=u""" %s %s @@ -316,7 +323,7 @@ def addPresentation2(self): """nothing""" #print "NAME:",file_name f=open(path+"/"+folder_name+"/"+file_name,"w") - f.write(xmlinfo) + f.write(xmlinfo.encode('utf-8')) f.close() try: os.chmod(path+"/"+folder_name,0775) @@ -389,7 +396,7 @@ def addText2(self): return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL2']+'?path='+path) def addTextExternal(self,path,texturl,version): - """hinzufügen eines externen textes""" + """hinzufuegen eines externen textes""" try: #neue text version einlesen texttemp=urllib.urlopen(texturl).readlines() text="" @@ -399,7 +406,7 @@ def addTextExternal(self,path,texturl,ve return "ERROR: cannot read: %s"%texturl if TextExternalError(text): #kein xml header return "ERROR: cannot read: %s"%texturl, "received:",text - textpath=getNewTextPath(path) #erzeuge neuen Ornder für den Text + textpath=getNewTextPath(path) #erzeuge neuen Ornder fuer den Text splitted=string.split(texturl,"/") name=splitted[len(splitted)-1] #Name des XML-files try: @@ -450,7 +457,7 @@ def addTextExternal(self,path,texturl,ve try: texttoolnodelist=subnode.getElementsByTagName('text') - if not len(texttoolnodelist)==0: #texttool tag existiert schon, dann löschen + if not len(texttoolnodelist)==0: #texttool tag existiert schon, dann loeschen subsubnode=subnode.removeChild(texttoolnodelist[0]) subsubnode.unlink() except: @@ -564,20 +571,23 @@ def readArchimedesXML(folder): def combineTextImage2(self,path): - """erstellt bzw. ändert texttool meta tag""" + """erstellt bzw. aendert texttool meta tag""" dom=xml.dom.minidom.parse(path+"/index.meta") node=dom.getElementsByTagName('meta')[0] #getNode subnodelist=node.getElementsByTagName('texttool') - if not len(subnodelist)==0: #texttool tag existiert schon, dann löschen + if not len(subnodelist)==0: #texttool tag existiert schon, dann loeschen subnode=node.removeChild(subnodelist[0]) subnode.unlink() subnode=dom.createElement('texttool') #neu erzeugen - presentfile=os.listdir(path+"/"+self.REQUEST['presentation'])[0] + presentfiles=os.listdir(path+"/"+self.REQUEST['presentation']) + for presentfileTmp in presentfiles: + if (presentfileTmp[0]!="."): #schliesse unsichbare DAteien aus. + presentfile=presentfileTmp displaynode=dom.createElement('display') @@ -700,27 +710,27 @@ def combineTextImage2(self,path): - urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines() - - if self.REQUEST.has_key('image'): # falls bilder - path=re.sub('//','/',self.REQUEST['path']) # falls '//' im Pfad - dlpath = re.sub('/mpiwg/online/','',path)+"/"+self.REQUEST['image'] - - zLOG.LOG('OSas',zLOG.INFO,"ssh archive@nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat -src=/mpiwg/online -dest=/mpiwg/temp/online/scaled/thumb -dir=%s -scaleto=100 -sync >> /tmp/sc.out &"%dlpath ) - ret=os.popen("ssh archive@nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat -src=/mpiwg/online -dest=/mpiwg/temp/online/scaled/thumb -dir=%s -scaleto=100 -sync >> /tmp/sc.out &"%dlpath ).read() - zLOG.LOG('OSAS (combine)',zLOG.INFO,ret) +# urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines() +# +# if self.REQUEST.has_key('image'): # falls bilder +# path=re.sub('//','/',self.REQUEST['path']) # falls '//' im Pfad +# dlpath = re.sub('/mpiwg/online/','',path)+"/"+self.REQUEST['image'] +# +# logger('OSas',logging.INFO,"ssh archive@nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat -src=/mpiwg/online -dest=/mpiwg/temp/online/scaled/thumb -dir=%s -scaleto=90 -sync >> /tmp/sc.out &"%dlpath ) +# ret=os.popen("ssh archive@nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat -src=/mpiwg/online -dest=/mpiwg/temp/online/scaled/thumb -dir=%s -scaleto=90 -sync >> /tmp/sc.out &"%dlpath ).read() +# logger('OSAS (combine)',logging.INFO,ret) - else: # falls keine Bilder (bug in reg.cgi info file ersetzen) - f=file("/tmp/tmp_info.xml","w") - tmp=patchedInfoXML(self.REQUEST['path']) - f.write(tmp.encode('utf-8')) - f.close() - splitted=path.split("/") - fn=splitted[len(splitted)-1] - remotePath="archive@nausikaa2.rz-berlin.mpg.de:/usr/local/share/archimedes/web/docs/proj/echo/1/docs/"+fn+"/info.xml" - os.popen("scp /tmp/tmp_info.xml %s"%remotePath) + #else: # falls keine Bilder (bug in reg.cgi info file ersetzen) + # f=file("/tmp/tmp_info.xml","w") + # tmp=patchedInfoXML(self.REQUEST['path']) + # f.write(tmp.encode('utf-8')) + # f.close() + # splitted=path.split("/") + # fn=splitted[len(splitted)-1] + # remotePath="archive@nausikaa2.rz-berlin.mpg.de:/usr/local/share/archimedes/web/docs/proj/echo/1/docs/"+fn+"/info.xml" + # os.popen("scp /tmp/tmp_info.xml %s"%remotePath) def patchedInfoXML(path): dom=xml.dom.minidom.parse(path+"/index.meta")