|
32 | 32 |
|
33 | 33 | __version__ = "2.1" |
34 | 34 |
|
35 | | -os.system("") |
| 35 | +if sys.platform == "win32": |
| 36 | + os.system("") |
36 | 37 |
|
37 | 38 |
|
38 | 39 | class ConnectionInfo: |
@@ -414,6 +415,12 @@ def update_speeds(self) -> None: |
414 | 415 | def get_stats_display(self) -> str: |
415 | 416 | """Get formatted statistics display""" |
416 | 417 |
|
| 418 | + if sys.stdout.isatty(): |
| 419 | + console_width = os.get_terminal_size().columns |
| 420 | + else: |
| 421 | + console_width = 80 |
| 422 | + # self.logger.debug("console_width=", console_width) |
| 423 | + |
417 | 424 | col_width = 30 |
418 | 425 |
|
419 | 426 | conns_stat = f"\033[97mTotal: \033[93m{self.total_connections}\033[0m".ljust( |
@@ -470,13 +477,13 @@ def get_stats_display(self) -> str: |
470 | 477 | ) |
471 | 478 | ) |
472 | 479 |
|
473 | | - title = "STATISTICS" |
| 480 | + title = " STATISTICS " |
474 | 481 |
|
475 | | - top_border = f"\033[92m{'═' * 36} {title} {'═' * 36}\033[0m" |
476 | | - line_conns = f"\033[92m {'Conns'.ljust(8)}:\033[0m {conns_stat}\033[0m" |
477 | | - line_traffic = f"\033[92m {'Traffic'.ljust(8)}:\033[0m {traffic_stat}\033[0m" |
478 | | - line_speed = f"\033[92m {'Speed'.ljust(8)}:\033[0m {speed_stat}\033[0m" |
479 | | - bottom_border = f"\033[92m{'═' * (36*2+len(title)+2)}\033[0m" |
| 482 | + top_border = f"\033[92m{title:═^{console_width}}\033[0m" |
| 483 | + line_conns = f"\033[92m{'Conns'.ljust(8)}:\033[0m {conns_stat}\033[0m" |
| 484 | + line_traffic = f"\033[92m{'Traffic'.ljust(8)}:\033[0m {traffic_stat}\033[0m" |
| 485 | + line_speed = f"\033[92m{'Speed'.ljust(8)}:\033[0m {speed_stat}\033[0m" |
| 486 | + bottom_border = f"\033[92m{'═' * console_width}\033[0m" |
480 | 487 |
|
481 | 488 | return ( |
482 | 489 | f"{top_border}\n{line_conns}\n{line_traffic}\n{line_speed}\n{bottom_border}" |
@@ -1018,10 +1025,10 @@ async def print_banner(self) -> None: |
1018 | 1025 | ░░░░░ ░░░░░ ░░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░\033[0m |
1019 | 1026 | """ |
1020 | 1027 | ) |
1021 | | - self.logger.info(f"\033[92mVersion: {__version__}".center(50)) |
| 1028 | + self.logger.info(f"\033[92mVersion: {__version__}".center(console_width)) |
1022 | 1029 | self.logger.info( |
1023 | 1030 | "\033[97m" + |
1024 | | - "Enjoy watching! / Наслаждайтесь просмотром!".center(50) |
| 1031 | + "Enjoy watching! / Наслаждайтесь просмотром!".center(console_width) |
1025 | 1032 | ) |
1026 | 1033 |
|
1027 | 1034 | self.logger.info("\n") |
@@ -1294,6 +1301,9 @@ def parse_args(): |
1294 | 1301 | """Parse command line arguments""" |
1295 | 1302 |
|
1296 | 1303 | parser = argparse.ArgumentParser() |
| 1304 | + parser.add_argument( |
| 1305 | + "-q", "--quiet", action="store_true", help="Remove UI output" |
| 1306 | + ) |
1297 | 1307 | parser.add_argument("--host", default="127.0.0.1", help="Proxy host") |
1298 | 1308 | parser.add_argument("--port", type=int, |
1299 | 1309 | default=8881, help="Proxy port") |
@@ -1332,9 +1342,6 @@ def parse_args(): |
1332 | 1342 | parser.add_argument( |
1333 | 1343 | "--log-error", required=False, help="Path to log file for errors" |
1334 | 1344 | ) |
1335 | | - parser.add_argument( |
1336 | | - "-q", "--quiet", action="store_true", help="Remove UI output" |
1337 | | - ) |
1338 | 1345 |
|
1339 | 1346 | autostart_group = parser.add_mutually_exclusive_group() |
1340 | 1347 | autostart_group.add_argument( |
|
0 commit comments