- configfilename = '.s3cfg'
- fd = os.open(configfilename, os.O_CREAT | os.O_TRUNC | os.O_WRONLY, 0o600)
- os.write(fd, '[default]\n'.encode('utf-8'))
- os.write(fd, ('access_key = ' + config['awsaccesskeyid'] + '\n').encode('utf-8'))
- os.write(fd, ('secret_key = ' + config['awssecretkey'] + '\n').encode('utf-8'))
- os.close(fd)
+ if os.path.exists(USER_S3CFG):
+ logging.info(_('Using "{path}" for configuring s3cmd.').format(path=USER_S3CFG))
+ configfilename = USER_S3CFG
+ else:
+ fd = os.open(AUTO_S3CFG, os.O_CREAT | os.O_TRUNC | os.O_WRONLY, 0o600)
+ logging.debug(_('Creating "{path}" for configuring s3cmd.').format(path=AUTO_S3CFG))
+ os.write(fd, '[default]\n'.encode('utf-8'))
+ os.write(fd, ('access_key = ' + config['awsaccesskeyid'] + '\n').encode('utf-8'))
+ os.write(fd, ('secret_key = ' + config['awssecretkey'] + '\n').encode('utf-8'))
+ os.close(fd)
+ configfilename = AUTO_S3CFG