|
12 | 12 | import pyzstd as zstd |
13 | 13 | import aiohttp |
14 | 14 | from tqdm import tqdm |
15 | | -import subprocess |
16 | | -import re |
| 15 | + |
17 | 16 | from . import web |
18 | 17 | from . import utils, logger, config, scheduler, units, storages, i18n |
19 | 18 | from .storages import File as SFile |
@@ -753,34 +752,6 @@ async def callback(data: tuple[Any, Any]): |
753 | 752 | scheduler.cancel(timeout_task) |
754 | 753 | return fut.result() |
755 | 754 |
|
756 | | -class Tunnel(): |
757 | | - def __init__(self,tunnel_program: str,output_regex: str,timeout: int=30): |
758 | | - self.tunnel_program = tunnel_program |
759 | | - self.output_regex = output_regex |
760 | | - self.timeout = timeout |
761 | | - self.output_logs = [] |
762 | | - async def create_tunnel(self): |
763 | | - process = subprocess.Popen( |
764 | | - [self.tunnel_program], |
765 | | - stdout=subprocess.PIPE, |
766 | | - stderr=subprocess.PIPE, |
767 | | - text=True |
768 | | - ) |
769 | | - for line in process.stdout: |
770 | | - self.output_logs.append(line.strip()) |
771 | | - async def get_tunnel_info(self): |
772 | | - regex = re.compile(self.output_regex) |
773 | | - for log in self.output_logs: |
774 | | - match = regex.search(log) |
775 | | - if match: |
776 | | - host = match.group('host') |
777 | | - port = match.group('port') |
778 | | - return {'host': host, 'port': port} |
779 | | - raise ValueError("无法获取隧道信息") |
780 | | - async def get_port(self): |
781 | | - return (await self.get_tunnel_info()).get('port',1145) |
782 | | - |
783 | | - |
784 | 755 | @dataclass |
785 | 756 | class ClusterCertificate: |
786 | 757 | host: str |
|
0 commit comments