mirror of https://github.com/zulip/zulip.git
tooling: Fix `manage.py` failing if `/etc/zulip/zulip.conf` exists.
If `/etc/zulip/zulip.conf` exists in development, `manage.py` fails unnecessarily. Instead, check if `deploy_type` is set, as done in `settings.py`. Fix #10931.
This commit is contained in:
parent
c8cbf39a16
commit
339fa86373
10
manage.py
10
manage.py
|
@ -3,6 +3,7 @@ from __future__ import (print_function)
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import types
|
import types
|
||||||
|
import configparser
|
||||||
if sys.version_info <= (3, 0):
|
if sys.version_info <= (3, 0):
|
||||||
print("Error: Zulip is a Python 3 project, and cannot be run with Python 2.")
|
print("Error: Zulip is a Python 3 project, and cannot be run with Python 2.")
|
||||||
print("Use e.g. `/path/to/manage.py` not `python /path/to/manage.py`.")
|
print("Use e.g. `/path/to/manage.py` not `python /path/to/manage.py`.")
|
||||||
|
@ -15,8 +16,13 @@ from scripts.lib.zulip_tools import assert_not_running_as_root
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
assert_not_running_as_root()
|
assert_not_running_as_root()
|
||||||
if (os.access('/etc/zulip/zulip.conf', os.R_OK) and not
|
|
||||||
os.access('/etc/zulip/zulip-secrets.conf', os.R_OK)):
|
config_file = configparser.RawConfigParser()
|
||||||
|
config_file.read("/etc/zulip/zulip.conf")
|
||||||
|
PRODUCTION = config_file.has_option('machine', 'deploy_type')
|
||||||
|
HAS_SECRETS = os.access('/etc/zulip/zulip-secrets.conf', os.R_OK)
|
||||||
|
|
||||||
|
if PRODUCTION and not HAS_SECRETS:
|
||||||
# The best way to detect running manage.py as another user in
|
# The best way to detect running manage.py as another user in
|
||||||
# production before importing anything that would require that
|
# production before importing anything that would require that
|
||||||
# access is to check for access to /etc/zulip/zulip.conf (in
|
# access is to check for access to /etc/zulip/zulip.conf (in
|
||||||
|
|
Loading…
Reference in New Issue