|
|
|
@@ -12,6 +12,7 @@ from xmlrpc.server import SimpleXMLRPCServer
|
|
|
|
|
from xmlrpc.client import ServerProxy
|
|
|
|
|
import logging
|
|
|
|
|
import os
|
|
|
|
|
import io
|
|
|
|
|
import zlib
|
|
|
|
|
import os.path
|
|
|
|
|
import requests
|
|
|
|
@@ -70,7 +71,6 @@ def run_tasks():
|
|
|
|
|
|
|
|
|
|
def replication_task():
|
|
|
|
|
while True:
|
|
|
|
|
print()
|
|
|
|
|
conn = db.connect_db()
|
|
|
|
|
with Session(conn) as session:
|
|
|
|
|
for bndname in connected:
|
|
|
|
@@ -241,7 +241,7 @@ def replication(bnd_name: str, commit_id: str, schema: str):
|
|
|
|
|
ET.SubElement(res, 'replication', {'id': commit_id, 'scheme': schema})
|
|
|
|
|
response_params = {
|
|
|
|
|
'from': f'tcp://{Config.self_bnd}',
|
|
|
|
|
'to': f'tcp://{Config.remote_bnd}',
|
|
|
|
|
'to': f'tcp://{bnd_name}',
|
|
|
|
|
'ts_added': date.timestamp(),
|
|
|
|
|
'user_id': '0',
|
|
|
|
|
'query_type': NEW_REPLICATION_REQUEST,
|
|
|
|
@@ -540,18 +540,20 @@ def put_object(params, files, url):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def apply_commits(params, files, url):
|
|
|
|
|
logger.warning(params, files, url)
|
|
|
|
|
logger.warning(params)
|
|
|
|
|
assert len(files) == 1
|
|
|
|
|
file = files[0]
|
|
|
|
|
logger.warning(file)
|
|
|
|
|
dir = TemporaryDirectory()
|
|
|
|
|
with zipfile.ZipFile(file, 'r') as zip_ref:
|
|
|
|
|
r = requests.get(file['url'])
|
|
|
|
|
with zipfile.ZipFile(io.BytesIO(r.content)) as zip_ref:
|
|
|
|
|
zip_ref.extractall(dir.name)
|
|
|
|
|
req = ET.fromstring(params['query_data'])
|
|
|
|
|
repl = req.find('replication')
|
|
|
|
|
scheme = repl.get('scheme')
|
|
|
|
|
commit = repl.get('id')
|
|
|
|
|
logger.warning(scheme, commit)
|
|
|
|
|
os.path.join(dir.name, 'export.o5c')
|
|
|
|
|
logger.warning(scheme)
|
|
|
|
|
logger.warning(commit)
|
|
|
|
|
con = OOConnectionParams(scheme, Config.oodb_host, Config.oodb_port, Config.oodb_dbname,
|
|
|
|
|
Config.oodb_username, Config.oodb_passwd, scheme)
|
|
|
|
|
ws = OODBWorkspace.ws(scheme)
|
|
|
|
@@ -561,10 +563,10 @@ def apply_commits(params, files, url):
|
|
|
|
|
oe = IpdExporter(ws)
|
|
|
|
|
oe.improtFromOsm(os.path.join(dir.name, 'export.o5c'))
|
|
|
|
|
oe.improtFromMbtiles(os.path.join(dir.name, 'export.mbtiles'))
|
|
|
|
|
with open('export_files.json', 'r') as f:
|
|
|
|
|
with open(os.path.join(dir.name, 'export_files.json'), 'r') as f:
|
|
|
|
|
files_data = json.load(f)
|
|
|
|
|
for file_data in files_data:
|
|
|
|
|
upload_file(file_data['filename'], file_data['key'], file_data['bucket'])
|
|
|
|
|
upload_file(os.path.join(dir.name, file_data['key']), file_data['key'], file_data['bucket'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_task(query_type, params, files, url):
|
|
|
|
|