def _lock_contents(self, jf, steps_ahead=0): conn = MockS3Connection(mock_s3_fs=self.mock_s3_fs) bucket = conn.get_bucket('my_bucket') lock_key_name = 'locks/%s/%d' % ( jf.jobflowid, len(jf.steps) + steps_ahead) key = bucket.get_key(lock_key_name) if key is None: return None else: return key.get_contents_as_string()
def mock_boto_connect_s3(*args, **kwargs): kwargs['mock_s3_fs'] = self.mock_s3_fs # keep track of credentials passed explicitly to connect_s3() if 'aws_access_key_id' in kwargs: self.aws_access_key_id = kwargs['aws_access_key_id'] if 'aws_secret_access_key' in kwargs: self.aws_secret_access_key = kwargs['aws_secret_access_key'] return MockS3Connection(*args, **kwargs)
def mock_boto_connect_s3(*args, **kwargs): kwargs['mock_s3_fs'] = self.mock_s3_fs return MockS3Connection(*args, **kwargs)