Diff for /OSA_system2/OSAS_server.py between versions 1.12 and 1.21

version 1.12, 2005/03/04 14:53:40 version 1.21, 2007/01/31 14:30:29
Line 8  import base64 Line 8  import base64
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile  from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 from Globals import InitializeClass,package_home  from Globals import InitializeClass,package_home
 from OFS.SimpleItem import SimpleItem  from OFS.SimpleItem import SimpleItem
   import logging
   import sys
   
   #ersetzt logging
   def logger(txt,method,txt2):
       """logging"""
       logging.info(txt+ txt2)
   
   
   
 def encodeRPC(string):  def encodeRPC(string):
     return base64.encodestring(bz2.compress(string))      return base64.encodestring(bz2.compress(string))
   def decodeRPC(string):
       return bz2.decompress(base64.decodestring(string))
   
   
 class OSAS_storeOnlineServer(SimpleItem):  class OSAS_storeOnlineServer(SimpleItem):
Line 19  class OSAS_storeOnlineServer(SimpleItem) Line 30  class OSAS_storeOnlineServer(SimpleItem)
           
     meta_type="OSAS_server"      meta_type="OSAS_server"
   
     def getImages(path):      def __init__(self,id):
           """initalize osas_server"""
           self.id = id
           
       def getImages(self,path):
         """hack"""          """hack"""
         imageEnding=['.gif','.jpg','.jpeg','.png','.tiff','.tif']          imageEnding=['.gif','.jpg','.jpeg','.png','.tiff','.tif']
   
         dirs=os.listdir(path)          dirs=os.listdir(path)
         ret=[]          ret=[]
   
         for dir in dirs:          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)):                  for subdir in os.listdir(os.path.join(path,dir)):
                     if os.path.splitext(subdir)[1].lower() in imageEnding:                      if os.path.splitext(subdir)[1].lower() in imageEnding:
                         ret.append(os.path.join(dir,subdir))                          ret.append(os.path.join(dir,subdir))
Line 35  class OSAS_storeOnlineServer(SimpleItem) Line 54  class OSAS_storeOnlineServer(SimpleItem)
         return ret          return ret
           
   
     def getMovies(path):      def getMovies(self,path):
         """hack"""          """hack"""
         movieEnding=['.dv','.mov','.mp4']          movieEnding=['.dv','.mov','.mp4']
         dirs=os.listdir(path)          dirs=os.listdir(path)
         ret=[]          ret=[]
         for dir in dirs:          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)):                  for subdir in os.listdir(os.path.join(path,dir)):
                     if os.path.splitext(subdir)[1].lower() in movieEnding:                      if os.path.splitext(subdir)[1].lower() in movieEnding:
                         ret.append(os.path.join(dir,subdir))                          ret.append(os.path.join(dir,subdir))
             else:              else:
                 if os.path.splitext(dir)[1] in imageEnding:                  if os.path.splitext(dir)[1] in movieEnding:
                         ret.append(os.path.join(dir))                          ret.append(os.path.join(dir))
         return ret          return ret
           
Line 114  class OSAS_storeOnlineServer(SimpleItem) Line 133  class OSAS_storeOnlineServer(SimpleItem)
         """getFile"""          """getFile"""
   
         if not os.path.exists(path):          if not os.path.exists(path):
             print "sorry"  
             return None              return None
   
         f=file(path,'r')          f=file(path,'r')
Line 132  class OSAS_storeOnlineServer(SimpleItem) Line 150  class OSAS_storeOnlineServer(SimpleItem)
             compressed=encodeRPC(file(path+"/index.meta","r").read())              compressed=encodeRPC(file(path+"/index.meta","r").read())
             ret["."]=('OSAS_dir',compressed)              ret["."]=('OSAS_dir',compressed)
         for dir in os.listdir(path):          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))              fileType=OSAS_helpers.checkOSASFileType(os.path.join(path,dir))
             if os.path.exists(os.path.join(path,dir,"index.meta")):              if os.path.exists(os.path.join(path,dir,"index.meta")):
                 compressed=encodeRPC(file(os.path.join(path,dir,"index.meta"),"r").read())                  compressed=encodeRPC(file(os.path.join(path,dir,"index.meta"),"r").read())
Line 140  class OSAS_storeOnlineServer(SimpleItem) Line 159  class OSAS_storeOnlineServer(SimpleItem)
                 ret[dir]=(fileType,None)                  ret[dir]=(fileType,None)
         return ret          return ret
   
     def writeMetaDataFile(self,path,metadata):      def writeMetaDataFile(self,path,metadata,compressed=None):
         """writefiletoserver"""          """writefiletoserver"""
           if compressed:
               metadata=decodeRPC(metadata)
               
         try:          try:
             fh=file(path,"w")              fh=file(path,"w")
             fh.write(metadata)              fh.write(metadata)
             fh.close              fh.close
             return True              return True
         except:          except:
               zLOG.LOG("SERVER (writeMetadataFile)",zLOG.ERROR,"%s (%s)"%sys.exc_info()[0:2])                        
             return False              return False
           
       def generateMovieThumb(self,input,output):
           """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):  def manage_addOSAS_storeOnlineServerForm(self):
     """interface for adding the OSAS_storeOnline"""      """interface for adding the OSAS_storeOnline"""

Removed from v.1.12  
changed lines
  Added in v.1.21


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>