mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-25 18:05:26 +00:00
Fix: [ALAS] Allow removing non-existent forwards and reverses
This commit is contained in:
parent
7c8d41614f
commit
d5f641aeb4
@ -513,30 +513,51 @@ class Connection(ConnectionAttr):
|
|||||||
def adb_forward_remove(self, local):
|
def adb_forward_remove(self, local):
|
||||||
"""
|
"""
|
||||||
Equivalent to `adb -s <serial> forward --remove <local>`
|
Equivalent to `adb -s <serial> forward --remove <local>`
|
||||||
|
No error raised when removing a non-existent forward
|
||||||
|
|
||||||
More about the commands send to ADB server, see:
|
More about the commands send to ADB server, see:
|
||||||
https://cs.android.com/android/platform/superproject/+/master:packages/modules/adb/SERVICES.TXT
|
https://cs.android.com/android/platform/superproject/+/master:packages/modules/adb/SERVICES.TXT
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
local (str): Such as 'tcp:2437'
|
local (str): Such as 'tcp:2437'
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
with self.adb_client._connect() as c:
|
with self.adb_client._connect() as c:
|
||||||
list_cmd = f"host-serial:{self.serial}:killforward:{local}"
|
list_cmd = f"host-serial:{self.serial}:killforward:{local}"
|
||||||
c.send_command(list_cmd)
|
c.send_command(list_cmd)
|
||||||
c.check_okay()
|
c.check_okay()
|
||||||
|
except AdbError as e:
|
||||||
|
# No error raised when removing a non-existed forward
|
||||||
|
# adbutils.errors.AdbError: listener 'tcp:8888' not found
|
||||||
|
msg = str(e)
|
||||||
|
if re.search(r'listener .*? not found', msg):
|
||||||
|
logger.warning(f'{type(e).__name__}: {msg}')
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
def adb_reverse_remove(self, local):
|
def adb_reverse_remove(self, local):
|
||||||
"""
|
"""
|
||||||
Equivalent to `adb -s <serial> reverse --remove <local>`
|
Equivalent to `adb -s <serial> reverse --remove <local>`
|
||||||
|
No error raised when removing a non-existent reverse
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
local (str): Such as 'tcp:2437'
|
local (str): Such as 'tcp:2437'
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
with self.adb_client._connect() as c:
|
with self.adb_client._connect() as c:
|
||||||
c.send_command(f"host:transport:{self.serial}")
|
c.send_command(f"host:transport:{self.serial}")
|
||||||
c.check_okay()
|
c.check_okay()
|
||||||
list_cmd = f"reverse:killforward:{local}"
|
list_cmd = f"reverse:killforward:{local}"
|
||||||
c.send_command(list_cmd)
|
c.send_command(list_cmd)
|
||||||
c.check_okay()
|
c.check_okay()
|
||||||
|
except AdbError as e:
|
||||||
|
# No error raised when removing a non-existed forward
|
||||||
|
# adbutils.errors.AdbError: listener 'tcp:8888' not found
|
||||||
|
msg = str(e)
|
||||||
|
if re.search(r'listener .*? not found', msg):
|
||||||
|
logger.warning(f'{type(e).__name__}: {msg}')
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
def adb_push(self, local, remote):
|
def adb_push(self, local, remote):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user