--- OSA_system2/OSAS_server.py 2005/03/17 19:26:52 1.15 +++ OSA_system2/OSAS_server.py 2007/01/31 14:30:29 1.21 @@ -8,10 +8,20 @@ import base64 from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Globals import InitializeClass,package_home from OFS.SimpleItem import SimpleItem -import zLOG +import logging +import sys + +#ersetzt logging +def logger(txt,method,txt2): + """logging""" + logging.info(txt+ txt2) + + def encodeRPC(string): return base64.encodestring(bz2.compress(string)) +def decodeRPC(string): + return bz2.decompress(base64.decodestring(string)) class OSAS_storeOnlineServer(SimpleItem): @@ -140,6 +150,7 @@ class OSAS_storeOnlineServer(SimpleItem) compressed=encodeRPC(file(path+"/index.meta","r").read()) ret["."]=('OSAS_dir',compressed) for dir in os.listdir(path): + zLOG.LOG("SERVER",zLOG.INFO,"get all index meta in %s"%dir) fileType=OSAS_helpers.checkOSASFileType(os.path.join(path,dir)) if os.path.exists(os.path.join(path,dir,"index.meta")): compressed=encodeRPC(file(os.path.join(path,dir,"index.meta"),"r").read()) @@ -148,21 +159,25 @@ class OSAS_storeOnlineServer(SimpleItem) ret[dir]=(fileType,None) return ret - def writeMetaDataFile(self,path,metadata): + def writeMetaDataFile(self,path,metadata,compressed=None): """writefiletoserver""" + if compressed: + metadata=decodeRPC(metadata) + try: fh=file(path,"w") fh.write(metadata) fh.close return True except: + zLOG.LOG("SERVER (writeMetadataFile)",zLOG.ERROR,"%s (%s)"%sys.exc_info()[0:2]) return False def generateMovieThumb(self,input,output): - """generate Movie""" - zLOG.LOG("SERVER",zLOG.INFO,"/usr/local/bin/thumbbite.pl %s %s"%(input,output)) - ret=os.popen("/usr/local/bin/thumbbite.pl %s %s"%(input,output)) - zLOG.LOG("SERVER",zLOG.INFO,ret) + """generate Movie""" + logger("SERVER",logging.INFO,"/usr/local/bin/thumbbite.pl %s %s"%(input,output)) + ret=os.popen("/usr/local/bin/thumbbite.pl %s %s"%(input,output)) + logger("SERVER",logging.INFO,ret) return "ok" def manage_addOSAS_storeOnlineServerForm(self):