Correcting replication and no_files flag
All checks were successful
Build xmlrpcserver image / Build (push) Successful in 56s
All checks were successful
Build xmlrpcserver image / Build (push) Successful in 56s
This commit is contained in:
76
main.py
76
main.py
@@ -80,6 +80,15 @@ def get_branch(bndname: str, scheme: str):
|
||||
return None, None
|
||||
|
||||
|
||||
def get_profile(bndname: str, scheme: str):
|
||||
conn = db.connect_db()
|
||||
with Session(conn) as session:
|
||||
item = session.query(db.Profile).filter_by(scheme=scheme).join(db.User).filter_by(bndname=bndname).one_or_none()
|
||||
if item:
|
||||
return item
|
||||
return None
|
||||
|
||||
|
||||
def run_tasks():
|
||||
logger.debug('Task thread started.')
|
||||
while True:
|
||||
@@ -256,6 +265,8 @@ def replication(bnd_name: str, commit_id: str, schema: str):
|
||||
rxmls = RequestXmlService()
|
||||
res_id = uuid4().hex
|
||||
|
||||
profile = get_profile(bndname=bnd_name, scheme=schema)
|
||||
|
||||
res = rxmls.get_request_document(res_id, None)
|
||||
rxmls.set_result(res, 0, '')
|
||||
ET.SubElement(res, 'replication', {'id': commit_id, 'scheme': schema})
|
||||
@@ -307,22 +318,23 @@ def replication(bnd_name: str, commit_id: str, schema: str):
|
||||
qu.setUids(created)
|
||||
ws.load(qu, uids)
|
||||
exported_files = []
|
||||
for feature_uid in uids:
|
||||
feature = ws.featureByUid(feature_uid)
|
||||
if not feature:
|
||||
continue
|
||||
for attr in feature.attributes('c1000'):
|
||||
updated_files.append(variantToFileValue(attr.val()))
|
||||
# updated_files.append(feature_uid)
|
||||
for x in updated_files:
|
||||
exported_files.append({
|
||||
'key': x.key,
|
||||
'bucket': x.bucket,
|
||||
'filename': x.fileName,
|
||||
})
|
||||
fp = os.path.join(z.dirname, x.key)
|
||||
os.makedirs(os.path.dirname(fp), exist_ok=True)
|
||||
download_file(x.key, x.bucket, fp)
|
||||
if not profile or not profile.no_files:
|
||||
for feature_uid in uids:
|
||||
feature = ws.featureByUid(feature_uid)
|
||||
if not feature:
|
||||
continue
|
||||
for attr in feature.attributes('c1000'):
|
||||
updated_files.append(variantToFileValue(attr.val()))
|
||||
# updated_files.append(feature_uid)
|
||||
for x in updated_files:
|
||||
exported_files.append({
|
||||
'key': x.key,
|
||||
'bucket': x.bucket,
|
||||
'filename': x.fileName,
|
||||
})
|
||||
fp = os.path.join(z.dirname, x.key)
|
||||
os.makedirs(os.path.dirname(fp), exist_ok=True)
|
||||
download_file(x.key, x.bucket, fp)
|
||||
with open(os.path.join(z.dirname, 'export_files.json'), 'w') as f:
|
||||
f.write(json.dumps(exported_files))
|
||||
ws.clearData(True)
|
||||
@@ -898,6 +910,38 @@ async def correction_replication(bnd_name: str, schema: str):
|
||||
logger.error('Error sending')
|
||||
|
||||
|
||||
@app.get("/get_cr")
|
||||
async def correction_replication(bnd_name: str, schema: str):
|
||||
|
||||
date = datetime.datetime.now()
|
||||
rxmls = RequestXmlService()
|
||||
res_id = uuid4().hex
|
||||
|
||||
res = rxmls.get_request_document(res_id, None)
|
||||
|
||||
con = OOConnectionParams(schema, Config.oodb_host, Config.oodb_port, Config.oodb_dbname,
|
||||
Config.oodb_username, Config.oodb_passwd, schema)
|
||||
ws = OODBWorkspace.ws(schema)
|
||||
if not ws.isInit():
|
||||
res = ws.init(con)
|
||||
logger.warning(res)
|
||||
ET.SubElement(res, 'commit', {'id': ws.currentCommit(), 'schema': schema})
|
||||
|
||||
params = {
|
||||
'from': f'tcp://{Config.self_bnd}',
|
||||
'to': f'tcp://{bnd_name}',
|
||||
'ts_added': date.timestamp(),
|
||||
'user_id': '0',
|
||||
'query_type': NEW_COMMIT_RESPONSE,
|
||||
'query_data': ET.tostring(res, encoding='unicode', xml_declaration=True),
|
||||
}
|
||||
proxy = ServerProxy(Config.enserver)
|
||||
try:
|
||||
proxy.send(params, [], Config.ret_path)
|
||||
except:
|
||||
logger.error('Error sending')
|
||||
|
||||
|
||||
def main():
|
||||
global connection
|
||||
global server
|
||||
|
||||
Reference in New Issue
Block a user