#NEWLINE# def _init( creds , bucket , multiple_env , environment , prefix , s3_cache_expire ) : #NEWLINE# #INDENT# '\n    Connect to S3 and download the metadata for each file in all buckets\n    specified and cache the data to disk.\n    ' #NEWLINE# cache_file = _get_buckets_cache_filename ( bucket , prefix ) #NEWLINE# exp = ( time . time ( ) - s3_cache_expire ) #NEWLINE# if os . path . isfile ( cache_file ) : #NEWLINE# #INDENT# cache_file_mtime = os . path . getmtime ( cache_file ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# cache_file_mtime = 0 #NEWLINE# #UNINDENT# expired = ( cache_file_mtime <= exp ) #NEWLINE# log . debug ( 'S3 bucket cache file {0} is {1}expired, mtime_diff={2}s, expiration={3}s' . format ( cache_file , ( '' if expired else 'not ' ) , ( cache_file_mtime - exp ) , s3_cache_expire ) ) #NEWLINE# if expired : #NEWLINE# #INDENT# pillars = _refresh_buckets_cache_file ( creds , cache_file , multiple_env , environment , prefix ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# pillars = _read_buckets_cache_file ( cache_file ) #NEWLINE# #UNINDENT# log . debug ( 'S3 bucket retrieved pillars {0}' . format ( pillars ) ) #NEWLINE# return pillars