30 lines
807 B
Python
Executable File
30 lines
807 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""每日同步钉钉组织架构。"""
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
import config
|
|
|
|
local_password = ROOT / '.local-test-db-password'
|
|
if local_password.exists():
|
|
config.DB_CONFIG.update({
|
|
'user': 'dy_test',
|
|
'password': local_password.read_text(encoding='ascii').strip(),
|
|
'unix_socket': '/run/mysqld/mysqld.sock',
|
|
})
|
|
|
|
from services.dingtalk_organization import sync_organization
|
|
|
|
|
|
if __name__ == '__main__':
|
|
try:
|
|
print(json.dumps(sync_organization('scheduled'), ensure_ascii=False))
|
|
except Exception as exc:
|
|
print(json.dumps({'status': 'failed', 'message': str(exc)}, ensure_ascii=False), file=sys.stderr)
|
|
raise SystemExit(1)
|