mirror of https://github.com/zulip/zulip.git
tools: Extract get_provisioning_status check logic.
Move get_provisioning_status check logic into assert_provisioning_status_ok and use it instead of duplicating the check code.
This commit is contained in:
parent
80a3651cf3
commit
b2b49089fd
|
@ -49,17 +49,12 @@ sys.path.insert(0, ZULIP_PATH)
|
|||
from tools.lib import sanity_check
|
||||
sanity_check.check_venv(__file__)
|
||||
|
||||
from tools.lib.test_script import get_provisioning_status
|
||||
from tools.lib.test_script import assert_provisioning_status_ok
|
||||
from tools.lib.test_server import test_server_running
|
||||
|
||||
from typing import Iterable, List
|
||||
|
||||
if not options.force:
|
||||
ok, msg = get_provisioning_status()
|
||||
if not ok:
|
||||
print(msg)
|
||||
print('If you really know what you are doing, use --force to run anyway.')
|
||||
sys.exit(1)
|
||||
assert_provisioning_status_ok(options.force)
|
||||
|
||||
os.chdir(ZULIP_PATH)
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ root_dir = os.path.dirname(tools_dir)
|
|||
sys.path.insert(0, root_dir)
|
||||
|
||||
from tools.lib.test_script import (
|
||||
get_provisioning_status,
|
||||
assert_provisioning_status_ok,
|
||||
)
|
||||
|
||||
def run():
|
||||
|
@ -20,12 +20,7 @@ def run():
|
|||
help='Run tests despite possible problems.')
|
||||
options = parser.parse_args()
|
||||
|
||||
if not options.force:
|
||||
ok, msg = get_provisioning_status()
|
||||
if not ok:
|
||||
print(msg)
|
||||
print('If you really know what you are doing, use --force to run anyway.')
|
||||
sys.exit(1)
|
||||
assert_provisioning_status_ok(options.force)
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from typing import Optional, Tuple
|
||||
|
||||
import os
|
||||
import sys
|
||||
from distutils.version import LooseVersion
|
||||
from version import PROVISION_VERSION
|
||||
from scripts.lib.zulip_tools import get_dev_uuid_var_path
|
||||
|
@ -70,3 +71,13 @@ def get_provisioning_status():
|
|||
return False, preamble(version) + NEED_TO_DOWNGRADE
|
||||
|
||||
return False, preamble(version) + NEED_TO_UPGRADE
|
||||
|
||||
|
||||
def assert_provisioning_status_ok(force):
|
||||
# type: (bool) -> None
|
||||
if not force:
|
||||
ok, msg = get_provisioning_status()
|
||||
if not ok:
|
||||
print(msg)
|
||||
print('If you really know what you are doing, use --force to run anyway.')
|
||||
sys.exit(1)
|
||||
|
|
|
@ -44,17 +44,12 @@ def run():
|
|||
from tools.linter_lib.pep8 import check_pep8
|
||||
|
||||
from tools.lib.test_script import (
|
||||
get_provisioning_status,
|
||||
assert_provisioning_status_ok,
|
||||
)
|
||||
|
||||
os.chdir(root_dir)
|
||||
|
||||
if not args.force:
|
||||
ok, msg = get_provisioning_status()
|
||||
if not ok:
|
||||
print(msg)
|
||||
print('If you really know what you are doing, use --force to run anyway.')
|
||||
sys.exit(1)
|
||||
assert_provisioning_status_ok(args.force)
|
||||
|
||||
backend_file_types = ['py', 'sh', 'pp', 'json', 'md', 'txt', 'text', 'yaml', 'rst']
|
||||
frontend_file_types = ['js', 'ts', 'css', 'scss', 'handlebars', 'html']
|
||||
|
|
|
@ -44,7 +44,7 @@ to this file.
|
|||
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.insert(0, os.path.dirname(TOOLS_DIR))
|
||||
from tools.lib.test_script import (
|
||||
get_provisioning_status,
|
||||
assert_provisioning_status_ok,
|
||||
)
|
||||
|
||||
parser.add_argument('--test',
|
||||
|
@ -67,12 +67,7 @@ parser.add_argument('--enable-tornado-logging',
|
|||
default=False, help='Enable access logs from tornado proxy server.')
|
||||
options = parser.parse_args()
|
||||
|
||||
if not options.force:
|
||||
ok, msg = get_provisioning_status()
|
||||
if not ok:
|
||||
print(msg)
|
||||
print('If you really know what you are doing, use --force to run anyway.')
|
||||
sys.exit(1)
|
||||
assert_provisioning_status_ok(options.force)
|
||||
|
||||
if options.interface is None:
|
||||
user_id = os.getuid()
|
||||
|
|
|
@ -13,7 +13,7 @@ TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|||
os.chdir(os.path.dirname(TOOLS_DIR))
|
||||
|
||||
sys.path.append(os.path.dirname(TOOLS_DIR))
|
||||
from lib.test_script import get_provisioning_status
|
||||
from lib.test_script import assert_provisioning_status_ok
|
||||
|
||||
exclude = """
|
||||
stubs/
|
||||
|
@ -38,12 +38,7 @@ parser.add_argument('--force', action="store_true",
|
|||
help="run tests despite possible provisioning problems")
|
||||
args = parser.parse_args()
|
||||
|
||||
if not args.force:
|
||||
ok, msg = get_provisioning_status()
|
||||
if not ok:
|
||||
print(msg)
|
||||
print('If you really know what you are doing, use --force to run anyway.')
|
||||
sys.exit(1)
|
||||
assert_provisioning_status_ok(args.force)
|
||||
|
||||
command_name = "mypy" if (args.no_daemon or args.version) else "dmypy"
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ os.chdir(ZULIP_PATH)
|
|||
|
||||
from zulip import Client
|
||||
|
||||
from tools.lib.test_script import get_provisioning_status
|
||||
from tools.lib.test_script import assert_provisioning_status_ok
|
||||
from tools.lib.test_server import test_server_running
|
||||
from zerver.lib.api_test_helpers import test_the_api, test_invalid_api_key
|
||||
|
||||
|
@ -31,12 +31,7 @@ parser.add_argument('--force', dest='force',
|
|||
default=False, help='Run tests despite possible provisioning problems.')
|
||||
options = parser.parse_args()
|
||||
|
||||
if not options.force:
|
||||
ok, msg = get_provisioning_status()
|
||||
if not ok:
|
||||
print(msg)
|
||||
print('If you really know what you are doing, use --force to run anyway.')
|
||||
sys.exit(1)
|
||||
assert_provisioning_status_ok(options.force)
|
||||
|
||||
with test_server_running(force=options.force, external_host='zulipdev.com:9981'):
|
||||
print("Running API tests...")
|
||||
|
|
|
@ -196,7 +196,7 @@ def main() -> None:
|
|||
from zerver.lib.test_fixtures import update_test_databases_if_required
|
||||
|
||||
from tools.lib.test_script import (
|
||||
get_provisioning_status,
|
||||
assert_provisioning_status_ok,
|
||||
)
|
||||
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.test_settings'
|
||||
|
@ -351,12 +351,7 @@ def main() -> None:
|
|||
if full_suite and include_webhooks:
|
||||
suites.append("zerver.webhooks")
|
||||
|
||||
if not options.force:
|
||||
ok, msg = get_provisioning_status()
|
||||
if not ok:
|
||||
print(msg)
|
||||
print('If you really know what you are doing, use --force to run anyway.')
|
||||
sys.exit(1)
|
||||
assert_provisioning_status_ok(options.force)
|
||||
|
||||
if options.coverage:
|
||||
import coverage
|
||||
|
|
|
@ -105,14 +105,9 @@ parser.add_argument('--force', dest='force',
|
|||
parser.add_argument('args', nargs=argparse.REMAINDER)
|
||||
options = parser.parse_args()
|
||||
|
||||
from tools.lib.test_script import get_provisioning_status
|
||||
from tools.lib.test_script import assert_provisioning_status_ok
|
||||
|
||||
if not options.force:
|
||||
ok, msg = get_provisioning_status()
|
||||
if not ok:
|
||||
print(msg)
|
||||
print('If you really know what you are doing, use --force to run anyway.')
|
||||
sys.exit(1)
|
||||
assert_provisioning_status_ok(options.force)
|
||||
|
||||
os.environ['NODE_PATH'] = 'static'
|
||||
os.environ['TZ'] = 'UTC'
|
||||
|
|
Loading…
Reference in New Issue