4 tables: publisher_platform/content/task/log 10 platforms: weibo/douyin/bilibili/kuaishou/wechat/xiaohongshu/toutiao/youtube/twitter Sage-compliant: DSPY no-import delegation, init.py→ServerEnv, scripts/load_path.py Content types: article/video/audio/image with per-platform format adapters
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
"""
|
|
内容发布模块 — 独立权限注册
|
|
在 Sage 环境中: python scripts/load_path.py
|
|
"""
|
|
import os, sys, subprocess
|
|
|
|
def find_sage_root():
|
|
for candidate in [os.path.expanduser(d) for d in ['~/repos/sage','~/sage','~/py/sage']]:
|
|
if os.path.isdir(os.path.join(candidate, 'py3', 'bin')):
|
|
return candidate
|
|
try:
|
|
import load_path as _
|
|
return os.path.dirname(os.path.abspath(_.__file__))
|
|
except ImportError:
|
|
pass
|
|
print('ERROR: Sage root not found'); sys.exit(1)
|
|
|
|
SAGE_ROOT = os.environ.get('SAGE_ROOT', find_sage_root())
|
|
PY = os.path.join(SAGE_ROOT, 'py3', 'bin', 'python')
|
|
SP = os.path.join(SAGE_ROOT, 'set_role_perm.py')
|
|
MOD = 'publisher'
|
|
|
|
PATHS_LOGINED = [
|
|
f'/{MOD}', f'/{MOD}/index.ui', f'/{MOD}/publish.dspy', f'/{MOD}/stats.dspy',
|
|
f'/{MOD}_platform', f'/{MOD}_platform/%',
|
|
f'/{MOD}_content', f'/{MOD}_content/%',
|
|
f'/{MOD}_task', f'/{MOD}_task/%',
|
|
f'/{MOD}_log', f'/{MOD}_log/%',
|
|
]
|
|
|
|
def set_perm(role, path):
|
|
env = os.environ.copy()
|
|
env['SAGE_RBAC_DB'] = 'sage'
|
|
subprocess.run([PY, SP, role, path], cwd=SAGE_ROOT, capture_output=True, env=env)
|
|
|
|
def main():
|
|
for p in PATHS_LOGINED:
|
|
set_perm('logined', p)
|
|
print(f'Registered {len(PATHS_LOGINED)} publisher paths')
|
|
|
|
if __name__ == '__main__':
|
|
main()
|