def download_data(filename, merge, java_application):
 oldrecords = []
 oldfile = None
 if merge:
  try:
   oldfile = open(filename, 'rb')
  except IOError:
   logging.info('No file to merge. Creating new file %s', filename)
 if oldfile:
  logging.info('Merging with existing file %s', filename)
  oldrecords = loader.UnpickleFromFile(oldfile)
  oldfile.close()
 if oldrecords:
  last_timestamp = oldrecords[0].start_timestamp_milliseconds()
  records = loader.FromMemcache(filter_timestamp=last_timestamp, java_application=java_application)
 else:
  records = loader.FromMemcache(java_application=java_application)
 merged_records = (records + oldrecords)
 try:
  outfile = open(filename, 'wb')
 except IOError:
  logging.error('Cannot open %s', filename)
  return
 loader.PickleToFile(merged_records, outfile)
 outfile.close()

def download_data ( filename , merge , java_application ) : oldrecords = [ ] oldfile = None if merge : try : oldfile = open ( filename , 'rb' ) except IOError : logging . info ( 'No file to merge. Creating new file %s' , filename ) if oldfile : logging . info ( 'Merging with existing file %s' , filename ) oldrecords = loader . UnpickleFromFile ( oldfile ) oldfile . close ( ) if oldrecords : last_timestamp = oldrecords [ 0 ] . start_timestamp_milliseconds ( ) records = loader . FromMemcache ( filter_timestamp = last_timestamp , java_application = java_application ) else : records = loader . FromMemcache ( java_application = java_application ) merged_records = ( records + oldrecords ) try : outfile = open ( filename , 'wb' ) except IOError : logging . error ( 'Cannot open %s' , filename ) return loader . PickleToFile ( merged_records , outfile ) outfile . close ( )
download appstats data from memcache .