Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复了使用/bs4对蓝叠4进行连接的一个bug #93

Merged
merged 2 commits into from
Jan 4, 2023
Merged

修复了使用/bs4对蓝叠4进行连接的一个bug #93

merged 2 commits into from
Jan 4, 2023

Conversation

GamerNoTitle
Copy link
Contributor

Bug描述

在使用/bs4进行连接时,发现无法连接,看控制台报的错误为

[2023-01-03 20:15:12,689][ERROR]<fgo.Device> can only concatenate str (not "int") to str
Traceback (most recent call last):
  File "F:\Git\FGO-py\FGO-py\FGO-py\fgoDevice.py", line 14, in convert
    try:return(lambda args:helpers[args[0][1:]](*args[1:]))(text.split('_'))
  File "F:\Git\FGO-py\FGO-py\FGO-py\fgoDevice.py", line 14, in <lambda>
    try:return(lambda args:helpers[args[0][1:]](*args[1:]))(text.split('_'))
  File "F:\Git\FGO-py\FGO-py\FGO-py\fgoDevice.py", line 24, in bs4
    with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,rf'SOFTWARE\BlueStacks_bgp64_hyperv\Guests\Android{f"_{args[0]}"if args else""}\Config')as key:return'127.0.0.1:'+winreg.QueryValueEx(key,"BstAdbPort")[0]
TypeError: can only concatenate str (not "int") to str

解决方案

fgoDevice.py的第24行,进行变量类型转换

    with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,rf'SOFTWARE\BlueStacks_bgp64_hyperv\Guests\Android{f"_{args[0]}"if args else""}\Config')as key:return'127.0.0.1:'+str(winreg.QueryValueEx(key,"BstAdbPort")[0])

@hgjazhgj hgjazhgj added the bug Something isn't working label Jan 3, 2023
@hgjazhgj
Copy link
Owner

hgjazhgj commented Jan 3, 2023

感谢您的pr!
c26c70f
原本这里是个f-string的,添加/bs5适配的时候给我改成string concatenate了,为的是上下文一致看起来优美...而我确实换了模拟器就没有测试
所以还是用f-string吧(

return f'127.0.0.1:{winreg.QueryValueEx(key,"BstAdbPort")[0]}'

@hgjazhgj hgjazhgj changed the base branch from master to dev January 3, 2023 19:02
@GamerNoTitle
Copy link
Contributor Author

改好啦 :D

@hgjazhgj hgjazhgj merged commit b08f83e into hgjazhgj:dev Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants