debug_poll3.py
1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os, sys
sys.path.insert(0, '/data/data/com.termux/files/home/local-testkit')
import hermes_wechat_daemon as d
d.load_config()
d.setup_logging(d.config.get('logging', {}))
# Check if hermes_work already exists
work_dir = '/data/data/com.termux/files/home/hermes_work'
print('work_dir exists=', os.path.exists(work_dir))
if os.path.exists(work_dir):
files = os.listdir(work_dir)
print('work_dir files=', files)
for f in files:
p = os.path.join(work_dir, f)
print(' ', f, os.path.getsize(p))
# Simulate poll_cycle exactly
src = d.config.get('db_src_path', '')
if not src:
src = d.find_enmicromsg_db()
termux_home = '/data/data/com.termux/files/home'
work_dir = os.path.join(termux_home, 'hermes_work')
print('makedirs work_dir...')
os.makedirs(work_dir, exist_ok=True)
print('copy_db...')
copied = d.copy_db(src, work_dir)
print('copied=', copied)
enc = os.path.join(work_dir, 'EnMicroMsg.db')
plain = os.path.join(termux_home, 'EnMicroMsg.db.decrypted.db')
print('enc exists=', os.path.exists(enc))
print('enc size=', os.path.getsize(enc) if os.path.exists(enc) else 0)
if os.path.exists(plain):
os.remove(plain)
print('removed old plain')
print('calling decrypt_db...')
ok = d.decrypt_db(enc, plain, d.config.get('sqlcipher_key'), 1024, 1)
print('decrypt ok=', ok)
print('plain exists=', os.path.exists(plain))
if os.path.exists(plain):
print('plain size=', os.path.getsize(plain))