Files
kefu/deploy/protocol-file-identity-20260917/finish_file_identity.py
T
2026-09-21 10:34:06 +08:00

18 lines
766 B
Python

from pathlib import Path
import os
path=Path(r'C:\wechat_rpa\wecom_native_sender.py')
text=path.read_text(encoding='utf-8')
old=""" after=_file_identity(os.fstat(handle.fileno()))
if before!=after or before!=_path_file_identity(path):
raise NativeUnavailable('企业微信文件在校验期间发生变化,请重新检测')
"""
new=""" after=_file_identity(os.fstat(handle.fileno()))
if before!=after or before!=_path_file_identity(path):
raise NativeUnavailable('企业微信文件在校验期间发生变化,请重新检测')
"""
assert old in text
text=text.replace(old,new,1)
compile(text,str(path),'exec')
temp=path.with_suffix('.identity-fix-tmp');temp.write_text(text,encoding='utf-8');os.replace(temp,path)