labpack/storage/aws/s3.py
def load(self, record_key, secret_key=''):
        
        '''
            a method to retrieve byte data of an S3 record

        :param record_key: string with name of record
        :param secret_key: [optional] string used to decrypt data
        :return: byte data for record body
        '''
        
        title = '%s.load' % self.__class__.__name__
    
    # validate inputs
        input_fields = {
            'record_key': record_key,
            'secret_key': secret_key
        }
        for key, value in input_fields.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, str(value))
                self.fields.validate(value, '.%s' % key, object_title)
    
    # retrieve record data from s3
        record_data, record_metadata = self.s3.read_record(self.bucket_name, record_key)
    
    # validate secret key
        error_msg = '%s(secret_key="...") required to decrypt record "%s"' % (title, record_key)
        if 'encryption' in record_metadata['metadata'].keys():
            if record_metadata['metadata']['encryption'] == 'lab512':
                if not secret_key:
                    raise Exception(error_msg)
            else:
                self.s3.iam.printer('[WARNING]: %s uses unrecognized encryption method. Decryption skipped.' % record_key)
                secret_key = ''
                
    # decrypt (if necessary)
        if secret_key:
            from labpack.encryption import cryptolab
            record_data = cryptolab.decrypt(record_data, secret_key)
    
        return record_data

            a method to retrieve byte data of an S3 record

        :param record_key: string with name of record
        :param secret_key: [optional] string used to decrypt data
        :return: byte data for record body
        
a method to retrieve byte data of an S3 record
a method to retrieve byte data of an S3 record
def load(self, record_key, secret_key=''):
        title = '%s.load' % self.__class__.__name__
        input_fields = {
            'record_key': record_key,
            'secret_key': secret_key
        }
        for key, value in input_fields.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, str(value))
                self.fields.validate(value, '.%s' % key, object_title)
        record_data, record_metadata = self.s3.read_record(self.bucket_name, record_key)
        error_msg = '%s(secret_key="...") required to decrypt record "%s"' % (title, record_key)
        if 'encryption' in record_metadata['metadata'].keys():
            if record_metadata['metadata']['encryption'] == 'lab512':
                if not secret_key:
                    raise Exception(error_msg)
            else:
                self.s3.iam.printer('[WARNING]: %s uses unrecognized encryption method. Decryption skipped.' % record_key)
                secret_key = ''
        if secret_key:
            from labpack.encryption import cryptolab
            record_data = cryptolab.decrypt(record_data, secret_key)
        return record_data
def load ( self , record_key , secret_key = '' ) : title = '%s.load' % self . __class__ . __name__ input_fields = { 'record_key' : record_key , 'secret_key' : secret_key } for key , value in input_fields . items ( ) : if value : object_title = '%s(%s=%s)' % ( title , key , str ( value ) ) self . fields . validate ( value , '.%s' % key , object_title ) record_data , record_metadata = self . s3 . read_record ( self . bucket_name , record_key ) error_msg = '%s(secret_key="...") required to decrypt record "%s"' % ( title , record_key ) if 'encryption' in record_metadata [ 'metadata' ] . keys ( ) : if record_metadata [ 'metadata' ] [ 'encryption' ] == 'lab512' : if not secret_key : raise Exception ( error_msg ) else : self . s3 . iam . printer ( '[WARNING]: %s uses unrecognized encryption method. Decryption skipped.' % record_key ) secret_key = '' if secret_key : from labpack . encryption import cryptolab record_data = cryptolab . decrypt ( record_data , secret_key ) return record_data
a method to retrieve byte data of an S3 record
a method to retrieve byte data of an S3 record
'''
            a method to retrieve byte data of an S3 record

        :param record_key: string with name of record
        :param secret_key: [optional] string used to decrypt data
        :return: byte data for record body
        ''' # validate inputs # retrieve record data from s3 # validate secret key # decrypt (if necessary)
byte data for record body
byte data for record body
self
record_key
string with name of record
string with name of record
secret_key
[optional] string used to decrypt data
[ optional ] string used to decrypt data