ok-oldking / ok-oldking/ok-script

配置文件非法,导致找不到设备/app/游戏时,日志比较难读

Open
#28 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
739
Forks
208
Avg merge
7h 47m
Merged PRs (30d)
1

Description

现象:配置文件非法,导致找不到设备/app/游戏时,日志比较难读

代码位置:
此文件ok/gui/StartController.py
类StartController
方法check_device_error(self):
以下代码段

        try:
            device = og.device_manager.get_preferred_device()
            error_msg = self.tr("{} is not connected, please select the game window.").format(
                device['nick'])   # device为空时 此处异常
            logger.debug(f'test check_device_error msg: {error_msg}')
            if not device:  
                return self.tr('No game selected!')  #  device为空时 此分支走不到

在device为空时,device['nick'] 会抛异常 TypeError: 'NoneType' object is not subscriptable。 永远无法走到if not device分支内。 影响看日志。

建议:
if not device的分支往前面提取;或者device['nick']带一个device为空的判断

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in ok/gui/StartController.py at StartController.check_device_error(self), focusing on the path where get_preferred_device() returns no device. Verify the empty-device case before the nick lookup, then confirm that the resulting log is readable and no TypeError is raised.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.