zulip_tools: Extract get_deploy_root function.

Modified by tabbott from the original to preserve the implementation;
see https://github.com/zulip/zulip/pull/11295#discussion_r254925032
for why this is correct.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg 2019-02-06 16:32:34 -08:00 committed by Tim Abbott
parent 4826393ec4
commit 70bfcd3402
1 changed files with 8 additions and 2 deletions

View File

@ -80,6 +80,13 @@ def parse_cache_script_args(description):
args.verbose |= args.dry_run # Always print a detailed report in case of dry run.
return args
def get_deploy_root() -> str:
# This calls realpath twice to handle both symlinks and users
# running our scripts with relative paths from a current working
# directory of `scripts/`.
return os.path.realpath(os.path.dirname(os.path.dirname(
os.path.dirname(os.path.realpath(__file__)))))
def get_deployment_version(extract_path):
# type: (str) -> str
version = '0.0.0'
@ -122,8 +129,7 @@ if __name__ == '__main__':
def get_dev_uuid_var_path(create_if_missing=False):
# type: (bool) -> str
zulip_path = os.path.realpath(os.path.dirname(os.path.dirname(
os.path.dirname(os.path.realpath(__file__)))))
zulip_path = get_deploy_root()
uuid_path = os.path.join(os.path.realpath(os.path.dirname(zulip_path)), ".zulip-dev-uuid")
if os.path.exists(uuid_path):
with open(uuid_path) as f: