backend bug fix

This commit is contained in:
2023-11-13 22:03:45 +09:00
parent 55181f2c57
commit 5fb8fe53bb
9 changed files with 162 additions and 196 deletions

View File

@@ -7,6 +7,7 @@ import httpx
import deepdiff
import app.core.config as config
import os
from pathlib import Path
from app.db.session import SessionLocal
from app.db.crud import get_flows_by_app,get_activedomain
from app.core.auth import get_current_active_user,get_current_user
@@ -228,6 +229,8 @@ def getkintoneorgs(c:config.KINTONE_ENV):
return r.json()
def uploadkintonefiles(file,c:config.KINTONE_ENV):
if (file.endswith('alc_runtime.js') and config.DEPLOY_MODE == "DEV"):
return {'fileKey':file}
upload_files = {'file': open(file,'rb')}
headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE}
data ={'name':'file','filename':os.path.basename(file)}
@@ -264,7 +267,11 @@ def createappjs(app):
for flow in flows:
content[flow.eventid] = {'flowid':flow.flowid,'name':flow.name,'content':flow.content}
js = 'const alcflow=' + json.dumps(content)
fpath = os.path.join("Temp",f"alc_setting_{app}.js")
scriptdir = Path(__file__).resolve().parent
rootdir = scriptdir.parent.parent.parent.parent
fpath = os.path.join(rootdir,"Temp",f"alc_setting_{app}.js")
print(rootdir)
print(fpath)
with open(fpath,'w') as file:
file.write(js)
return fpath
@@ -524,4 +531,5 @@ async def createjstokintone(app:str,env = Depends(getkintoneenv)):
deoployappfromkintone(app,appjscs["revision"],env)
return appjscs
except Exception as e:
print(str(e))
raise HTTPException(status_code=400, detail=f"Error occurred : {str(e)}")