Thonny 自动设置时间

其它相关内容
问题讨论
回复
头像
shaoziyang
帖子: 3917
注册时间: 2019年 10月 21日 13:48

Thonny 自动设置时间

#1

帖子 shaoziyang »

同事在使用Thonny时,发现保存文件时会自动设置系统时间。分析了一下Thonny下载程序时,发现Thonny发送了下面命令:


try:

    from machine import RTC as __thonny_RTC
    try:
        __thonny_RTC()datetime((2021, 6, 16, 3, 16, 6, 0, 0))
    except:
        __thonny_RTC()init((2021, 6, 16, 16, 6, 0, 0, 0))
    del __thonny_RTC


    __thonny_helperprint_mgmt_value(True)
except Exception as e:
    __thonny_helperprint_mgmt_value(str(e))

try:
    __thonny_path = '/testpy'
    __thonny_written = 0
    __thonny_fp = open(__thonny_path, 'wb')
except Exception as e:
    print(str(e))

def __W(x):
    global __thonny_written
    __thonny_written += __thonny_fpwrite(x)
    __thonny_fpflush()
    if hasattr(__thonny_helperos, "sync"):
        __thonny_helperossync()
__W(b'print(1+2+3+4+5)')__thonny_helperprint_mgmt_value(__thonny_written)
try:
    del __W
    del __thonny_written
    del __thonny_path
    __thonny_fpclose()
    del __thonny_fp
    del __thonny_result
    del __thonny_unhex
except:
    pass

__thonny_result = {} 
try:
    __thonny_names = __thonny_helperlistdir('/')
except OSError:
    __thonny_helperprint_mgmt_value(None) 
else:
    for __thonny_name in __thonny_names:
        if not __thonny_namestartswith("") or False:
            try:
                __thonny_result[__thonny_name] = __thonny_helperosstat('/' + __thonny_name)
            except OSError as e:
                __thonny_result[__thonny_name] = str(e)
    __thonny_helperprint_mgmt_value(__thonny_result)

__thonny_result = {} 
try:
    __thonny_names = __thonny_helperlistdir('/')
except OSError:
    __thonny_helperprint_mgmt_value(None) 
else:
    for __thonny_name in __thonny_names:
        if not __thonny_namestartswith("") or False:
            try:
                __thonny_result[__thonny_name] = __thonny_helperosstat('/' + __thonny_name)
            except OSError as e:
                __thonny_result[__thonny_name] = str(e)
    __thonny_helperprint_mgmt_value(__thonny_result)

 

头像
shaoziyang
帖子: 3917
注册时间: 2019年 10月 21日 13:48

Re: Thonny 自动设置时间

#2

帖子 shaoziyang »

命令首先就是设置时间,并且会根据系统自动发送 datetime() 或 init(),从而让系统时间与计算机时间同步。

回复

  • 随机主题
    回复总数
    阅读次数
    最新文章