Exemplo n.º 1
0
def list_messages( vol_inst, pubkey_str, privkey_str, folder_name, start_timestamp=None, end_timestamp=None, length=None ):
   global STORAGE_DIR, CHECK_INCOMING_FOLDERS
   
   cached_items = storage.get_cached_data( privkey_str, folder_cache_name( folder_name ) )
   if cached_items == None:
      log.info("No cached data for %s" % folder_name)
   
   try:
      dir_ents = storage.listdir( folder_dir(folder_name) )
   except Exception, oe:
      log.error("Failed to list folder %s" % folder_name)
      log.exception(oe)
      raise Exception("Internal error")
Exemplo n.º 2
0
def list_contacts( pubkey_str, privkey_str, start_idx=None, length=None ):
   global STORAGE_DIR, CACHED_CONTACT_LIST
   
   cached_contacts = storage.get_cached_data( privkey_str, CACHED_CONTACT_LIST )
   if cached_contacts == None:
      log.info("No cached contacts")
   else:
      return cached_contacts
   
   contact_dir = storage.volume_path( STORAGE_DIR )   
   dir_ents = storage.listdir( contact_dir )
   dir_ents.sort()
   
   if start_idx == None:
      start_idx = 0
      
   if length == None:
      length = len(dir_ents)
   
   if start_idx + length > len(dir_ents):
      length = len(dir_ents) - start_idx
      
   dir_ents = dir_ents[start_idx:start_idx + length]
   
   contact_emails = []
   
   for contact_filename in dir_ents:
      contact_path = storage.path_join( contact_dir, contact_filename )
      contact = read_contact_from_path( privkey_str, contact_path )
      if contact == None:
         log.warning("Failed to read contact file %s" % contact_path)
         continue
   
      contact_emails.append( contact.addr )
   
   storage.cache_data( pubkey_str, CACHED_CONTACT_LIST, contact_emails )
   return contact_emails
Exemplo n.º 3
0
    dir_ents = storage.listdir( folder_dir(folder_name) )
 except Exception, oe:
    log.error("Failed to list folder %s" % folder_name)
    log.exception(oe)
    raise Exception("Internal error")
 
 # tag these dir entries as having come from the folder
 FROM_FOLDER = 1
 FROM_INCOMING = 2
 
 dir_ents = [(x, FROM_FOLDER) for x in dir_ents]
 
 if folder_name in CHECK_INCOMING_FOLDERS:
    # check incoming as well
    try:
       incoming_dir_ents = storage.listdir( incoming_dir(), volume=vol_inst )
    except OSError, oe:
       log.error("Failed to list folder, errno = %s" % oe.errno)
       log.exception(oe)
       raise Exception("Internal error")
    
    # tag these dir entries as having come from incoming
    incoming_dir_ents = [(x, FROM_INCOMING) for x in incoming_dir_ents]
    
    dir_ents += incoming_dir_ents
 
 # will sort on dir_ents[i][0]
 dir_ents.sort()
 dir_ents.reverse()
 
 # get all messages between start and end timestamps