zulip_tools.py: Add get_environment() function.

This function can be used to determine the environment in which a
script is being executed.
This commit is contained in:
Harshit Bansal
2017-08-18 17:14:09 +00:00
committed by Tim Abbott
parent 4825b6e5ad
commit 931e4752aa

View File

@@ -147,3 +147,11 @@ def log_management_command(cmd, log_path):
logger.setLevel(logging.INFO)
logger.info("Ran '%s'" % (cmd,))
def get_environment():
# type: () -> Text
if os.path.exists(DEPLOYMENTS_DIR):
return "prod"
if os.environ.get("TRAVIS"):
return "travis"
return "dev"