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:
1
db.py
1
db.py
@@ -77,6 +77,7 @@ class Profile(Base):
|
||||
scheme: Mapped[str]
|
||||
branch: 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')
|
||||
|
||||
|
||||
44
main.py
44
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,6 +318,7 @@ def replication(bnd_name: str, commit_id: str, schema: str):
|
||||
qu.setUids(created)
|
||||
ws.load(qu, uids)
|
||||
exported_files = []
|
||||
if not profile or not profile.no_files:
|
||||
for feature_uid in uids:
|
||||
feature = ws.featureByUid(feature_uid)
|
||||
if not feature:
|
||||
@@ -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