MCPcopy
hub / github.com/DedSecInside/TorBot / run

Function run

torbot/main.py:57–108  ·  view source on GitHub ↗
(arg_parser: argparse.ArgumentParser, version: str)

Source from the content-addressed store, hash-verified

55
56
57def run(arg_parser: argparse.ArgumentParser, version: str) -> None:
58 args = arg_parser.parse_args()
59
60 # setup logging
61 date_fmt = '%d-%b-%y %H:%M:%S'
62 logging_fmt = '%(asctime)s - %(levelname)s - %(message)s'
63 logging_lvl = logging.DEBUG if args.v else logging.INFO
64 logging.basicConfig(level=logging_lvl, format=logging_fmt, datefmt=date_fmt)
65
66 # URL is a required argument
67 if not args.url:
68 arg_parser.print_help()
69 sys.exit()
70
71 # Print verison then exit
72 if args.version:
73 print(f"TorBot Version: {version}")
74 sys.exit()
75
76 # check version and update if necessary
77 if args.update:
78 check_version()
79 sys.exit()
80
81 socks5_proxy = f'socks5://{socks5_host}:{socks5_port}'
82 with httpx.Client(timeout=60, proxies=socks5_proxy if not args.disable_socks5 else None) as client:
83 # print header and IP address if not set to quiet
84 if not args.quiet:
85 print_header(version)
86 print_tor_ip_address(client)
87
88 if args.info:
89 execute_all(client, args.url)
90
91 tree = LinkTree(url=args.url, depth=args.depth, client=client)
92 tree.load()
93
94 # save data if desired
95 if args.save == 'tree':
96 tree.save()
97 elif args.save == 'json':
98 tree.saveJSON()
99
100 # always print something, table is the default
101 if args.visualize == 'table' or not args.visualize:
102 tree.showTable()
103 elif args.visualize == 'tree':
104 print(tree)
105 elif args.visualize == 'json':
106 tree.showJSON()
107
108 print("\n\n")
109
110
111def set_arguments() -> argparse.ArgumentParser:

Callers 1

main.pyFile · 0.85

Calls 10

loadMethod · 0.95
saveMethod · 0.95
saveJSONMethod · 0.95
showTableMethod · 0.95
showJSONMethod · 0.95
check_versionFunction · 0.90
execute_allFunction · 0.90
LinkTreeClass · 0.90
print_headerFunction · 0.85
print_tor_ip_addressFunction · 0.85

Tested by

no test coverage detected