Correcting replication
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
|
||||
class Config:
|
||||
ret_path: str = 'http://10.10.8.81:9000/'
|
||||
ret_path: str = 'http://10.10.8.60:9000/'
|
||||
self_bnd: str = 'bnd127'
|
||||
enserver: str = 'http://127.0.0.1:7000/xmlrpc'
|
||||
remote_bnd: str = 'bnd128'
|
||||
|
||||
18
main.py
18
main.py
@@ -27,6 +27,7 @@ import boto3
|
||||
import db
|
||||
from sqlalchemy.orm import Session
|
||||
from fastapi import FastAPI, Response, Form, UploadFile, File, Request
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
import uvicorn
|
||||
from typing_extensions import Annotated
|
||||
import pathlib
|
||||
@@ -69,7 +70,7 @@ def get_branch(bndname: str, scheme: str):
|
||||
with Session(conn) as session:
|
||||
item = session.query(db.IncomeBranch).filter_by(scheme=scheme).join(db.User).filter_by(bndname=bndname).one_or_none()
|
||||
if item:
|
||||
return item.branch,item.local_scheme
|
||||
return item.branch, item.local_scheme
|
||||
return None, None
|
||||
|
||||
|
||||
@@ -562,6 +563,8 @@ def put_object(params, files, url):
|
||||
|
||||
|
||||
def apply_commits(params, files, url):
|
||||
logging.warning("Apply commits")
|
||||
logging.warning(params)
|
||||
assert len(files) == 1
|
||||
file = files[0]
|
||||
dir = TemporaryDirectory()
|
||||
@@ -579,11 +582,13 @@ def apply_commits(params, files, url):
|
||||
con = OOConnectionParams(scheme, Config.oodb_host, Config.oodb_port, Config.oodb_dbname,
|
||||
Config.oodb_username, Config.oodb_passwd, scheme)
|
||||
ws = OODBWorkspace.ws(scheme)
|
||||
logging.warning("Connected to schema")
|
||||
if Config.ws_rabbit_params and not ws.hasProducer():
|
||||
ws.setProducer(Config.ws_rabbit_params['host'], Config.ws_rabbit_params['port'],
|
||||
Config.ws_rabbit_params['exchange'], Config.ws_rabbit_params['user'],
|
||||
Config.ws_rabbit_params['password'])
|
||||
ws.setCurrentUser(bnd)
|
||||
logging.warning("Set branch if needed")
|
||||
if branch:
|
||||
logging.warning(branch)
|
||||
ws.switchBranch(branch)
|
||||
@@ -591,6 +596,7 @@ def apply_commits(params, files, url):
|
||||
res = ws.init(con)
|
||||
logger.warning(res)
|
||||
oe = IpdExporter(ws)
|
||||
logging.warning("Importing...")
|
||||
if not oe.importChanges(os.path.join(dir.name, 'export.o5c'), os.path.join(dir.name, 'export.mbtiles')):
|
||||
logging.warning(f'Error importing commit {commit}: {oe.lastError().text()}')
|
||||
else:
|
||||
@@ -599,6 +605,7 @@ def apply_commits(params, files, url):
|
||||
files_data = json.load(f)
|
||||
for file_data in files_data:
|
||||
upload_file(os.path.join(dir.name, file_data['key']), file_data['key'], file_data['bucket'])
|
||||
logging.warning("Finished import")
|
||||
ws.clearData(True)
|
||||
|
||||
|
||||
@@ -724,6 +731,12 @@ def xmlrpc_task():
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
app.add_middleware(CORSMiddleware,
|
||||
allow_origins=['http://10.10.8.24:3000'],
|
||||
allow_credentials=True,
|
||||
allow_methods=['*'],
|
||||
allow_headers=['*']
|
||||
)
|
||||
|
||||
|
||||
@app.get("/")
|
||||
@@ -779,8 +792,7 @@ async def fa_put_object(response: Response,
|
||||
|
||||
@app.get("/cr")
|
||||
async def correction_replication(bnd_name: str, schema: str):
|
||||
if Config.self_bnd != 'bnd127':
|
||||
return
|
||||
|
||||
date = datetime.datetime.now()
|
||||
rxmls = RequestXmlService()
|
||||
res_id = uuid4().hex
|
||||
|
||||
Reference in New Issue
Block a user