analytics/management/commands/check_analytics_state.py: Avoid shelling out for mv.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg
2018-07-18 17:50:15 -04:00
committed by Tim Abbott
parent f3b0b8edc8
commit 8d52f0e0c0

View File

@@ -12,7 +12,6 @@ from zerver.lib.timestamp import floor_to_hour, floor_to_day, verify_UTC, \
from zerver.models import Realm
import os
import subprocess
import sys
import time
from typing import Any, Dict
@@ -40,7 +39,7 @@ class Command(BaseCommand):
with open(state_file_tmp, "w") as f:
f.write("%s|%s|%s|%s\n" % (
int(time.time()), status, states[status], message))
subprocess.check_call(["mv", state_file_tmp, state_file_path])
os.rename(state_file_tmp, state_file_path)
def get_fill_state(self) -> Dict[str, Any]:
if not Realm.objects.exists():