mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
backup: Use simpler api for server version.
This commit is contained in:
committed by
Tim Abbott
parent
66bbf35df4
commit
9d46b41e25
@@ -2,12 +2,11 @@ import os
|
|||||||
import re
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
from argparse import ArgumentParser, RawTextHelpFormatter
|
from argparse import ArgumentParser, RawTextHelpFormatter
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import Any
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.management.base import CommandParser
|
from django.core.management.base import CommandParser
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
from django.db.backends.postgresql.base import DatabaseWrapper
|
|
||||||
from django.utils.timezone import now as timezone_now
|
from django.utils.timezone import now as timezone_now
|
||||||
|
|
||||||
from scripts.lib.zulip_tools import TIMESTAMP_FORMAT, parse_os_release, run
|
from scripts.lib.zulip_tools import TIMESTAMP_FORMAT, parse_os_release, run
|
||||||
@@ -52,13 +51,8 @@ class Command(ZulipBaseCommand):
|
|||||||
members.append("zulip-backup/os-version")
|
members.append("zulip-backup/os-version")
|
||||||
|
|
||||||
with open(os.path.join(tmp, "zulip-backup", "postgres-version"), "w") as f:
|
with open(os.path.join(tmp, "zulip-backup", "postgres-version"), "w") as f:
|
||||||
# We are accessing a backend specific attribute via a proxy object, whose type
|
pg_server_version = connection.cursor().connection.server_version
|
||||||
# cannot be narrowed with a regular isinstance assertion.
|
print(pg_server_version, file=f)
|
||||||
# This can be potentially fixed more cleanly with the recently added
|
|
||||||
# connection.get_database_version().
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
assert isinstance(connection, DatabaseWrapper)
|
|
||||||
print(connection.pg_version, file=f)
|
|
||||||
members.append("zulip-backup/postgres-version")
|
members.append("zulip-backup/postgres-version")
|
||||||
|
|
||||||
if settings.DEVELOPMENT:
|
if settings.DEVELOPMENT:
|
||||||
|
|||||||
Reference in New Issue
Block a user