File tree Expand file tree Collapse file tree 1 file changed +71
-0
lines changed Expand file tree Collapse file tree 1 file changed +71
-0
lines changed Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments