-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.py
71 lines (60 loc) · 2.98 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import autotraders
import click
from website.app import create_app
from website.config import BaseConfig
print(f" * Running autotraders version check for version v{autotraders.__version__}")
accepted_autotraders_major_version = 2
accepted_autotraders_minor_versions = [3]
warning_autotraders_minor_versions = []
min_server_support_patch = 3 # TODO: Minor version too
blacklisted_versions = []
autotraders_major_version = int(autotraders.__version__.split(".")[0])
autotraders_minor_version = int(autotraders.__version__.split(".")[1])
autotraders_patch_version = int(autotraders.__version__.split(".")[2])
if autotraders.__version__ in blacklisted_versions:
raise ValueError(
f"Please upgrade autotraders to v{accepted_autotraders_major_version}.{max(accepted_autotraders_minor_versions)}, your version has been blacklisted, which means it is likely no longer supported by the server."
)
if autotraders_major_version > accepted_autotraders_major_version:
raise ValueError(
f"Please downgrade autotraders to v{accepted_autotraders_major_version}.{max(accepted_autotraders_minor_versions)}"
)
if (
autotraders_minor_version not in accepted_autotraders_minor_versions
and autotraders_minor_version < min(accepted_autotraders_minor_versions)
):
raise ValueError(
f"Please upgrade autotraders to v{accepted_autotraders_major_version}.{max(accepted_autotraders_minor_versions)}"
)
elif (
autotraders_minor_version not in accepted_autotraders_minor_versions
and autotraders_minor_version < max(accepted_autotraders_minor_versions)
):
raise ValueError(
f"Please downgrade autotraders to v{accepted_autotraders_major_version}.{max(accepted_autotraders_minor_versions)}"
)
elif autotraders_minor_version not in accepted_autotraders_minor_versions:
raise ValueError(
f"Please install autotraders v{accepted_autotraders_major_version}.{max(accepted_autotraders_minor_versions)}"
)
elif autotraders_minor_version in warning_autotraders_minor_versions:
print(
f" * Warning: Autotraders v{autotraders.__version__} is not officially supported, but limited functionality might be available, proceed at your own risk."
)
if autotraders_patch_version < min_server_support_patch:
print(f" * Warning: Autotraders v{autotraders.__version__} is not officially supported because it is not compatible with the latest server version, but limited functionality might be available, proceed at your own risk.")
@click.command()
@click.option("--debug", is_flag=True)
@click.option("--port", default=5000)
@click.option("--threaded", is_flag=True)
@click.option("--db", default="sqlite:///local.db")
@click.option(
"--secret-key",
default="secret@!%(@!%!@)*(#$)*$@!)*@!%)*@!)*&%@!132509831207549035213028579674138",
)
def cmd(debug, port, threaded, db, secret_key):
BaseConfig.SECRET_KEY = secret_key
BaseConfig.SQLALCHEMY_DATABASE_URI = db
create_app().run(debug=debug, port=port, threaded=threaded)
if __name__ == "__main__":
cmd()