Make error message more precise for S3 access

The previous error message let think that you should set AWS_BUCKETNAME,
although you should set it only if you are trying to write in this
repository.
This commit is contained in:
Guewen Baconnier
2017-08-28 14:37:45 +02:00
parent e67626945e
commit f1e84b5562
+12 -8
View File
@@ -119,14 +119,18 @@ class IrAttachment(models.Model):
else: else:
bucket_name = os.environ.get('AWS_BUCKETNAME') bucket_name = os.environ.get('AWS_BUCKETNAME')
if not (access_key and secret_key and bucket_name): if not (access_key and secret_key and bucket_name):
raise exceptions.UserError( msg = _('If you want to read from the %s S3 bucket, the following '
_('The following environment variables must be set:\n' 'environment variables must be set:\n'
'* AWS_ACCESS_KEY_ID\n' '* AWS_ACCESS_KEY_ID\n'
'* AWS_SECRET_ACCESS_KEY\n' '* AWS_SECRET_ACCESS_KEY\n'
'* AWS_BUCKETNAME\n' 'If you want to write in the %s S3 bucket, this variable '
'* AWS_HOST (optional)\n' 'must be set as well:\n'
) '* AWS_BUCKETNAME\n'
) 'Optionally, the S3 host can be changed with:\n'
'* AWS_HOST\n'
) % (bucket_name, bucket_name)
raise exceptions.UserError(msg)
try: try:
conn = connect_s3(aws_access_key_id=access_key, conn = connect_s3(aws_access_key_id=access_key,