Skip to content

Commit b5b58ae

Browse files
authored
Merge pull request #815 from mikumifa/codex/fix-attributeerror-for-share-attribute
Add Gradio runtime flags to CLI entrypoint
2 parents c6a7b9f + df42285 commit b5b58ae

10 files changed

Lines changed: 33 additions & 186 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ test.py
2121
main.build
2222
main.dist
2323
.DS_Store
24+
bilitickerbuy.egg-info

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ ENV TZ=Asia/Shanghai
1616
COPY requirements.txt .
1717
RUN python -m pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
1818
COPY . .
19-
RUN playwright install chromium
2019
RUN apt-get update --allow-unauthenticated && \
2120
apt-get install -y --allow-unauthenticated --no-install-recommends \
2221
libnss3 libnspr4 libatk-bridge2.0-0 libdrm2 libxkbcommon0 \

bilitickerbuy.egg-info/PKG-INFO

Lines changed: 0 additions & 118 deletions
This file was deleted.

bilitickerbuy.egg-info/SOURCES.txt

Lines changed: 0 additions & 37 deletions
This file was deleted.

bilitickerbuy.egg-info/dependency_links.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

bilitickerbuy.egg-info/entry_points.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

bilitickerbuy.egg-info/requires.txt

Lines changed: 0 additions & 15 deletions
This file was deleted.

bilitickerbuy.egg-info/top_level.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

main.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,49 @@ def get_env_default(key: str, default, cast_func):
66
return cast_func(os.environ.get(f"BTB_{key}", default))
77

88

9+
def str_to_bool(value):
10+
if isinstance(value, bool):
11+
return value
12+
return str(value).strip().lower() in {"1", "true", "yes", "y", "on"}
13+
14+
915
def main():
16+
gradio_parent = argparse.ArgumentParser(add_help=False)
17+
gradio_parent.add_argument(
18+
"--share",
19+
action="store_true",
20+
default=get_env_default("SHARE", False, str_to_bool),
21+
help="Share Gradio app publicly (tunnel). Defaults to False.",
22+
)
23+
gradio_parent.add_argument(
24+
"--server_name",
25+
type=str,
26+
default=os.environ.get("BTB_SERVER_NAME", "127.0.0.1"),
27+
help='Server name for Gradio. Defaults to env "BTB_SERVER_NAME" or 127.0.0.1.',
28+
)
29+
gradio_parent.add_argument(
30+
"--port",
31+
type=int,
32+
default=int(
33+
os.environ.get("BTB_PORT", os.environ.get("GRADIO_SERVER_PORT", 7860))
34+
),
35+
help='Server port for Gradio. Defaults to env "BTB_PORT"/"GRADIO_SERVER_PORT" or 7860.',
36+
)
37+
1038
parser = argparse.ArgumentParser(
1139
description=(
1240
"BiliTickerBuy\n\n"
1341
"Use `btb buy` to buy tickets directly in the command line."
1442
"Run `btb` without arguments to open the UI."
43+
"Run `btb buy -h` for `btb buy` detailed options."
1544
),
1645
epilog=(
1746
"Examples:\n"
1847
" btb buy tickets.json\n"
1948
" btb buy tickets.json --interval 500\n\n"
20-
"Run `btb buy -h` for detailed options."
2149
),
2250
formatter_class=argparse.RawTextHelpFormatter,
51+
parents=[gradio_parent],
2352
)
2453
subparsers = parser.add_subparsers(
2554
dest="command",
@@ -30,6 +59,7 @@ def main():
3059
buy_parser = subparsers.add_parser(
3160
"buy",
3261
help="Buy tickets directly in the command line",
62+
parents=[gradio_parent],
3363
)
3464
# ===== Buy Core =====
3565
buy_core = buy_parser.add_argument_group("Buy Core Options")

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)