From ec5ed87ca0f9e82e7a50a6f02ad2935f39c3a88f Mon Sep 17 00:00:00 2001 From: Yoyo Zhou Date: Thu, 20 Aug 2015 21:51:35 -0700 Subject: [PATCH] Make get_secret return None instead of an exception if the secret isn't defined. Remove empty key generation from generate_enterprise_secrets, since get_secret ignores missing keys now. (imported from commit 32d61e3058f0d41bfb4b17775e581a3c84540fe7) --- scripts/setup/generate_enterprise_secrets.py | 6 ------ zproject/local_settings.py | 5 ++++- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/setup/generate_enterprise_secrets.py b/scripts/setup/generate_enterprise_secrets.py index 33a6001d46..8e2d3e31ae 100755 --- a/scripts/setup/generate_enterprise_secrets.py +++ b/scripts/setup/generate_enterprise_secrets.py @@ -16,9 +16,6 @@ CAMO_CONFIG_FILENAME = '/etc/default/camo' AUTOGENERATED_SETTINGS = ['shared_secret', 'avatar_salt', 'rabbitmq_password', 'local_database_password', 'initial_password_salt'] -EMPTY_SETTINGS = ['deployment_role_key', 'mandrill_api_key', 'mailchimp_api_key', 'email_password', 's3_key', 's3_secret_key', - 'google_oauth2_client_secret', 'dev_google_oauth2_client_secret'] - def generate_camo_config_file(camo_key): camo_config = """ENABLED=yes PORT=9292 @@ -54,9 +51,6 @@ def generate_secrets(development=False): # Write the Camo config file directly generate_camo_config_file(camo_key) - for name in EMPTY_SETTINGS: - lines.append(config_line(name, '')) - out = open(OUTPUT_SETTINGS_FILENAME, 'w') out.write("".join(lines)) out.close() diff --git a/zproject/local_settings.py b/zproject/local_settings.py index b15c34cac7..4df75ad062 100644 --- a/zproject/local_settings.py +++ b/zproject/local_settings.py @@ -21,7 +21,10 @@ if DEPLOYED: else: secrets_file.read("zproject/dev-secrets.conf") -get_secret = lambda x: secrets_file.get('secrets', x) +def get_secret(key): + if secrets_file.has_option('secrets', key): + return secrets_file.get('secrets', key) + return None MAILCHIMP_API_KEY = get_secret("mailchimp_api_key") ZULIP_FRIENDS_LIST_ID = '84b2f3da6b'