--- OSA_system2/OSAS_server.py 2005/03/04 14:53:40 1.12 +++ OSA_system2/OSAS_server.py 2005/11/29 10:39:50 1.18 @@ -8,6 +8,8 @@ import base64 from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Globals import InitializeClass,package_home from OFS.SimpleItem import SimpleItem +import zLOG +import sys def encodeRPC(string): return base64.encodestring(bz2.compress(string)) @@ -19,13 +21,21 @@ class OSAS_storeOnlineServer(SimpleItem) meta_type="OSAS_server" - def getImages(path): + def __init__(self,id): + """initalize osas_server""" + self.id = id + + def getImages(self,path): """hack""" imageEnding=['.gif','.jpg','.jpeg','.png','.tiff','.tif'] + dirs=os.listdir(path) ret=[] + for dir in dirs: - if os.path.isdir(dir): + + if os.path.isdir(os.path.join(path,dir)): + for subdir in os.listdir(os.path.join(path,dir)): if os.path.splitext(subdir)[1].lower() in imageEnding: ret.append(os.path.join(dir,subdir)) @@ -35,18 +45,18 @@ class OSAS_storeOnlineServer(SimpleItem) return ret - def getMovies(path): + def getMovies(self,path): """hack""" movieEnding=['.dv','.mov','.mp4'] dirs=os.listdir(path) ret=[] for dir in dirs: - if os.path.isdir(dir): + if os.path.isdir(os.path.join(path,dir)): for subdir in os.listdir(os.path.join(path,dir)): if os.path.splitext(subdir)[1].lower() in movieEnding: ret.append(os.path.join(dir,subdir)) else: - if os.path.splitext(dir)[1] in imageEnding: + if os.path.splitext(dir)[1] in movieEnding: ret.append(os.path.join(dir)) return ret @@ -114,7 +124,6 @@ class OSAS_storeOnlineServer(SimpleItem) """getFile""" if not os.path.exists(path): - print "sorry" return None f=file(path,'r') @@ -132,6 +141,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,9 +158,16 @@ class OSAS_storeOnlineServer(SimpleItem) fh.close return True except: + zLOG.LOG("SERVER (writeMetadataFile)",zLOG.ERROR,"%s (%s)"%sys.exc_info()[0:1]) 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) + return "ok" + def manage_addOSAS_storeOnlineServerForm(self): """interface for adding the OSAS_storeOnline""" pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addStoreOnlineServer.zpt')).__of__(self)