Skip to content

Commit 04e8eda

Browse files
committed
test issue 22
1 parent 7e2b025 commit 04e8eda

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

tests/argparse/test_22.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import asyncio
2+
from threading import Thread
3+
4+
from cli2gui import Cli2Gui
5+
6+
THREAD: Thread = None
7+
import argparse
8+
from pathlib import Path
9+
10+
11+
def main():
12+
parser = argparse.ArgumentParser(description="Web scraper with aria2c output")
13+
parser.add_argument(
14+
"urls_file",
15+
help="Input file containing URLs",
16+
type=argparse.FileType("r", encoding="utf-8"),
17+
)
18+
parser.add_argument(
19+
"aria2c_file",
20+
help="Output file for aria2c download links",
21+
type=Path,
22+
)
23+
parser.add_argument("--timeout", type=int, default=5000, help="Timeout per page (ms)")
24+
parser.add_argument("--max-workers", type=int, default=2, help="Maximum number of workers")
25+
parser.add_argument(
26+
"--save-trace",
27+
action="store_true",
28+
help="Save trace files (for debugging only)",
29+
)
30+
parser.add_argument(
31+
"--skip-edge",
32+
action="store_true",
33+
help="Don't use Edge",
34+
)
35+
args = parser.parse_args()
36+
blocking_run(args)
37+
38+
39+
def blocking_run(args):
40+
asyncio.run(run(args))
41+
42+
43+
async def run(args):
44+
print(args.timeout)
45+
46+
47+
def wrapper(args):
48+
global THREAD
49+
50+
if THREAD is not None and THREAD.is_alive():
51+
print("Task already running")
52+
return
53+
54+
print(args)
55+
56+
THREAD = Thread(target=blocking_run, args=(args,))
57+
THREAD.start()
58+
59+
60+
decorator_function = Cli2Gui(
61+
run_function=wrapper,
62+
auto_enable=True,
63+
program_name="Test program #22",
64+
gui="freesimplegui",
65+
)
66+
67+
68+
gui = decorator_function(main)
69+
70+
if __name__ == "__main__":
71+
gui()

0 commit comments

Comments
 (0)