支持Python 2.7的pylot

时间:2021-11-14 20:27:17

想用pylot测试一下板子上面的嵌入式web server。
结果报错。

E:\pylot_1.26>run.py -a 2
Traceback (most recent call last):
  File "E:\pylot_1.26\run.py", line 118, in <module>
    import ui.console as pylot_console
  File "E:\pylot_1.26\ui\console\__init__.py", line 1, in <module>
    from pylot_console import *
  File "E:\pylot_1.26\ui\console\pylot_console.py", line 28, in <module>
    import win.cpos as cpos
  File "E:\pylot_1.26\ui\console\win\cpos.py", line 25, in <module>
    getpos = _consolepos.getpos
NameError: name '_consolepos' is not defined

打开 cpos.py一看傻眼了

import sys

is_25 = sys.version.startswith('2.5')
is_26 = sys.version.startswith('2.6')

if is_25:
    import _consolepos25 as _consolepos
elif is_26:
    import _consolepos26 as _consolepos

getpos = _consolepos.getpos
gotoxy = _consolepos.gotoxy

只支持python2.5和python2.6,而且是使用DLL的方式。且pylot早就不更新了。


本打算试着改进一下的,结果搜到下面项目 https://github.com/AutoCoder/pylot
把这块改为不使用DLL,而是直接使用Python实现,clone下来成功在python2.7上面运行。