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

28 lines
1023 B
Python

import json
import os
from pathlib import Path
import sys
import time
sys.path.insert(0,r'C:\wechat_rpa')
sys.dont_write_bytecode=True
import wecom_native_sender as sender
path=Path(r'C:\Program Files (x86)\WXWork\WXWork.exe')
names=('st_dev','st_ino','st_size','st_mtime_ns','st_ctime_ns')
before=path.stat()
with path.open('rb') as stream:
opened=os.fstat(stream.fileno())
result={'python':sys.version,'path':str(path),
'path_stat':{name:getattr(before,name) for name in names},
'handle_fstat':{name:getattr(opened,name) for name in names}}
started=time.perf_counter()
try:
digest,identity=sender._hash_client_file(path)
result.update(ok=True,digest=digest,identity=identity)
except Exception as exc:
result.update(ok=False,error_type=type(exc).__name__,error=str(exc))
result['elapsed_ms']=round((time.perf_counter()-started)*1000,2)
target=Path(sys.argv[1])
target.write_text(json.dumps(result,ensure_ascii=False,indent=2),encoding='utf-8')
print(json.dumps(result,ensure_ascii=False))