Correcting replication and no_files flag
All checks were successful
Build xmlrpcserver image / Build (push) Successful in 56s

This commit is contained in:
Ivan Vazhenin
2024-04-08 20:30:34 +03:00
parent 219b597042
commit cdaccb911b
2 changed files with 61 additions and 16 deletions

1
db.py
View File

@@ -77,6 +77,7 @@ class Profile(Base):
scheme: Mapped[str] scheme: Mapped[str]
branch: Mapped[str] = mapped_column(String, nullable=True) branch: Mapped[str] = mapped_column(String, nullable=True)
json: Mapped[str] = mapped_column(String, nullable=True) json: Mapped[str] = mapped_column(String, nullable=True)
no_files: Mapped[bool]
user: Mapped['User'] = relationship(back_populates='profiles') user: Mapped['User'] = relationship(back_populates='profiles')

44
main.py
View File

@@ -80,6 +80,15 @@ def get_branch(bndname: str, scheme: str):
return None, None 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(): def run_tasks():
logger.debug('Task thread started.') logger.debug('Task thread started.')
while True: while True:
@@ -256,6 +265,8 @@ def replication(bnd_name: str, commit_id: str, schema: str):
rxmls = RequestXmlService() rxmls = RequestXmlService()
res_id = uuid4().hex res_id = uuid4().hex
profile = get_profile(bndname=bnd_name, scheme=schema)
res = rxmls.get_request_document(res_id, None) res = rxmls.get_request_document(res_id, None)
rxmls.set_result(res, 0, '') rxmls.set_result(res, 0, '')
ET.SubElement(res, 'replication', {'id': commit_id, 'scheme': schema}) ET.SubElement(res, 'replication', {'id': commit_id, 'scheme': schema})
@@ -307,6 +318,7 @@ def replication(bnd_name: str, commit_id: str, schema: str):
qu.setUids(created) qu.setUids(created)
ws.load(qu, uids) ws.load(qu, uids)
exported_files = [] exported_files = []
if not profile or not profile.no_files:
for feature_uid in uids: for feature_uid in uids:
feature = ws.featureByUid(feature_uid) feature = ws.featureByUid(feature_uid)
if not feature: if not feature:
@@ -898,6 +910,38 @@ async def correction_replication(bnd_name: str, schema: str):
logger.error('Error sending') 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(): def main():
global connection global connection
global server global server