refactor: workspace_base 从 appbase params 表读(去硬编码,params 表不存在时用默认值兜底)
This commit is contained in:
parent
af178f98ad
commit
ebcb89da56
@ -202,7 +202,14 @@ async def _exec_tool(sor, tool, params, ctx, uid, org_id):
|
||||
if ex: return f'FAIL: 项目「{name}」已存在'
|
||||
pid = getID()
|
||||
wid = getID()
|
||||
ws = f'/d/pipeline/workspaces/{org_id}/{name}'
|
||||
_wsb = '/d/pipeline/workspaces'
|
||||
try:
|
||||
_wbr = await sor.sqlExe("SELECT params_value FROM params WHERE params_name='workspace_base' LIMIT 1", {})
|
||||
if _wbr and getattr(_wbr[0], 'params_value', ''):
|
||||
_wsb = getattr(_wbr[0], 'params_value', '')
|
||||
except Exception:
|
||||
pass
|
||||
ws = _wsb + '/' + str(org_id) + '/' + name
|
||||
await sor.C('sd_projects',{'id':pid,'name':name,'description':p.get('description',''),'workspace_dir':ws,'org_id':org_id,'created_by':uid})
|
||||
await sor.C('sd_iterations',{'id':wid,'project_id':pid,'iteration_name':'默认迭代','iteration_type':'default','status':'active','priority':1,'org_id':org_id})
|
||||
await _save_ctx(sor, uid, pid)
|
||||
|
||||
@ -5,10 +5,16 @@ if not uid:
|
||||
uid = 'user-01'
|
||||
|
||||
dbname = get_module_dbname('pipeline-sdlc')
|
||||
workspace_base = '/d/pipeline/workspaces'
|
||||
import os
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
workspace_base = '/d/pipeline/workspaces'
|
||||
try:
|
||||
_wbr = await sor.sqlExe("SELECT params_value FROM params WHERE params_name='workspace_base' LIMIT 1", {})
|
||||
if _wbr and getattr(_wbr[0], 'params_value', ''):
|
||||
workspace_base = getattr(_wbr[0], 'params_value', '')
|
||||
except Exception:
|
||||
pass
|
||||
recs = await sor.sqlExe(
|
||||
"SELECT current_project_id FROM pipeline_agent_settings WHERE user_id=${u}$",
|
||||
{"u": uid})
|
||||
|
||||
@ -9,9 +9,15 @@ if not uid:
|
||||
uid = 'user-01'
|
||||
|
||||
dbname = get_module_dbname('pipeline-sdlc')
|
||||
workspace_base = '/d/pipeline/workspaces'
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
workspace_base = '/d/pipeline/workspaces'
|
||||
try:
|
||||
_wbr = await sor.sqlExe("SELECT params_value FROM params WHERE params_name='workspace_base' LIMIT 1", {})
|
||||
if _wbr and getattr(_wbr[0], 'params_value', ''):
|
||||
workspace_base = getattr(_wbr[0], 'params_value', '')
|
||||
except Exception:
|
||||
pass
|
||||
recs = await sor.sqlExe(
|
||||
"SELECT current_project_id FROM pipeline_agent_settings WHERE user_id=${u}$", {"u": uid})
|
||||
pid = getattr(recs[0], 'current_project_id', '') if recs else ''
|
||||
|
||||
@ -12,9 +12,15 @@ if not uid:
|
||||
uid = 'user-01'
|
||||
|
||||
dbname = get_module_dbname('pipeline-sdlc')
|
||||
workspace_base = '/d/pipeline/workspaces'
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
workspace_base = '/d/pipeline/workspaces'
|
||||
try:
|
||||
_wbr = await sor.sqlExe("SELECT params_value FROM params WHERE params_name='workspace_base' LIMIT 1", {})
|
||||
if _wbr and getattr(_wbr[0], 'params_value', ''):
|
||||
workspace_base = getattr(_wbr[0], 'params_value', '')
|
||||
except Exception:
|
||||
pass
|
||||
recs = await sor.sqlExe(
|
||||
"SELECT current_project_id FROM pipeline_agent_settings WHERE user_id=${u}$", {"u": uid})
|
||||
pid = getattr(recs[0], 'current_project_id', '') if recs else ''
|
||||
|
||||
@ -10,9 +10,15 @@ if not uid:
|
||||
uid = 'user-01'
|
||||
|
||||
dbname = get_module_dbname('pipeline-sdlc')
|
||||
workspace_base = '/d/pipeline/workspaces'
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
workspace_base = '/d/pipeline/workspaces'
|
||||
try:
|
||||
_wbr = await sor.sqlExe("SELECT params_value FROM params WHERE params_name='workspace_base' LIMIT 1", {})
|
||||
if _wbr and getattr(_wbr[0], 'params_value', ''):
|
||||
workspace_base = getattr(_wbr[0], 'params_value', '')
|
||||
except Exception:
|
||||
pass
|
||||
recs = await sor.sqlExe(
|
||||
"SELECT current_project_id FROM pipeline_agent_settings WHERE user_id=${u}$", {"u": uid})
|
||||
pid = getattr(recs[0], 'current_project_id', '') if recs else ''
|
||||
|
||||
@ -11,9 +11,15 @@ if not uid:
|
||||
uid = 'user-01'
|
||||
|
||||
dbname = get_module_dbname('pipeline-sdlc')
|
||||
workspace_base = '/d/pipeline/workspaces'
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
workspace_base = '/d/pipeline/workspaces'
|
||||
try:
|
||||
_wbr = await sor.sqlExe("SELECT params_value FROM params WHERE params_name='workspace_base' LIMIT 1", {})
|
||||
if _wbr and getattr(_wbr[0], 'params_value', ''):
|
||||
workspace_base = getattr(_wbr[0], 'params_value', '')
|
||||
except Exception:
|
||||
pass
|
||||
recs = await sor.sqlExe(
|
||||
"SELECT current_project_id FROM pipeline_agent_settings WHERE user_id=${u}$", {"u": uid})
|
||||
pid = getattr(recs[0], 'current_project_id', '') if recs else ''
|
||||
|
||||
@ -9,9 +9,17 @@ if not uid:
|
||||
uid = 'user-01'
|
||||
|
||||
dbname = get_module_dbname('pipeline-sdlc')
|
||||
workspace_base = '/d/pipeline/workspaces'
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
# workspace_base 从 appbase params 表读(可动态配置),默认值兜底
|
||||
workspace_base = '/d/pipeline/workspaces'
|
||||
try:
|
||||
_wbr = await sor.sqlExe(
|
||||
"SELECT params_value FROM params WHERE params_name='workspace_base' LIMIT 1", {})
|
||||
if _wbr and getattr(_wbr[0], 'params_value', ''):
|
||||
workspace_base = getattr(_wbr[0], 'params_value', '')
|
||||
except Exception:
|
||||
pass
|
||||
recs = await sor.sqlExe(
|
||||
"SELECT current_project_id FROM pipeline_agent_settings WHERE user_id=${u}$",
|
||||
{"u": uid})
|
||||
|
||||
@ -12,9 +12,15 @@ if not uid:
|
||||
uid = 'user-01'
|
||||
|
||||
dbname = get_module_dbname('pipeline-sdlc')
|
||||
workspace_base = '/d/pipeline/workspaces'
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
workspace_base = '/d/pipeline/workspaces'
|
||||
try:
|
||||
_wbr = await sor.sqlExe("SELECT params_value FROM params WHERE params_name='workspace_base' LIMIT 1", {})
|
||||
if _wbr and getattr(_wbr[0], 'params_value', ''):
|
||||
workspace_base = getattr(_wbr[0], 'params_value', '')
|
||||
except Exception:
|
||||
pass
|
||||
recs = await sor.sqlExe(
|
||||
"SELECT current_project_id FROM pipeline_agent_settings WHERE user_id=${u}$", {"u": uid})
|
||||
pid = getattr(recs[0], 'current_project_id', '') if recs else ''
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user