minor: Remove unnecessary path juggling in `get_recent_deployments()`.

This commit is contained in:
Harshit Bansal 2017-10-30 01:36:30 +05:30 committed by Tim Abbott
parent 669517c450
commit 1871d6fe1f
1 changed files with 5 additions and 4 deletions

View File

@ -199,19 +199,20 @@ def get_recent_deployments(threshold_days):
recent = set() recent = set()
threshold_date = datetime.datetime.now() - datetime.timedelta(days=threshold_days) threshold_date = datetime.datetime.now() - datetime.timedelta(days=threshold_days)
for dir_name in os.listdir(DEPLOYMENTS_DIR): for dir_name in os.listdir(DEPLOYMENTS_DIR):
if not os.path.isdir(os.path.join(DEPLOYMENTS_DIR, dir_name)): target_dir = os.path.join(DEPLOYMENTS_DIR, dir_name)
if not os.path.isdir(target_dir):
# Skip things like uwsgi sockets, symlinks, etc. # Skip things like uwsgi sockets, symlinks, etc.
continue continue
if not os.path.exists(os.path.join(DEPLOYMENTS_DIR, dir_name, "zerver")): if not os.path.exists(os.path.join(target_dir, "zerver")):
# Skip things like "lock" that aren't actually a deployment directory # Skip things like "lock" that aren't actually a deployment directory
continue continue
try: try:
date = datetime.datetime.strptime(dir_name, TIMESTAMP_FORMAT) date = datetime.datetime.strptime(dir_name, TIMESTAMP_FORMAT)
if date >= threshold_date: if date >= threshold_date:
recent.add(os.path.join(DEPLOYMENTS_DIR, dir_name)) recent.add(target_dir)
except ValueError: except ValueError:
# Always include deployments whose name is not in the format of a timestamp. # Always include deployments whose name is not in the format of a timestamp.
recent.add(os.path.join(DEPLOYMENTS_DIR, dir_name)) recent.add(target_dir)
if os.path.exists("/root/zulip"): if os.path.exists("/root/zulip"):
recent.add("/root/zulip") recent.add("/root/zulip")
return recent return recent