Add s3 files processing
This commit is contained in:
@@ -4,7 +4,9 @@ COPY . ./
|
|||||||
RUN cd deps/pygost-5.12/ && \
|
RUN cd deps/pygost-5.12/ && \
|
||||||
python3 setup.py install && \
|
python3 setup.py install && \
|
||||||
cd ../.. && \
|
cd ../.. && \
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt && \
|
||||||
|
mkdir -p /opt/tnt/bin && \
|
||||||
|
ln -s /usr/bin/python3 /opt/tnt/bin/python3
|
||||||
ENV LD_LIBRARY_PATH "/app"
|
ENV LD_LIBRARY_PATH "/app"
|
||||||
ENV PYTHONPATH "${PYTHONPATH}:/app"
|
ENV PYTHONPATH "${PYTHONPATH}:/app"
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
ret_path: str = 'http://10.10.8.60:9000/'
|
ret_path: str = 'http://10.10.8.81:9000/'
|
||||||
self_bnd: str = 'bnd127'
|
self_bnd: str = 'bnd127'
|
||||||
enserver: str = 'http://127.0.0.1:7000/xmlrpc'
|
enserver: str = 'http://127.0.0.1:7000/xmlrpc'
|
||||||
remote_bnd: str = 'bnd128'
|
remote_bnd: str = 'bnd128'
|
||||||
|
|||||||
12
config/response2.json
Normal file
12
config/response2.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"filestorage": {
|
||||||
|
"type": "s3",
|
||||||
|
"endpoint": "http://10.10.8.83:31006",
|
||||||
|
"key_id": "s57",
|
||||||
|
"access_key": "d9MMinLF3U8TLSj",
|
||||||
|
"download_path": "/tmp"
|
||||||
|
},
|
||||||
|
"file_code": "c1000",
|
||||||
|
"name_code": "c122",
|
||||||
|
"use_version": true
|
||||||
|
}
|
||||||
167
config/workspaces.json
Normal file
167
config/workspaces.json
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
{
|
||||||
|
"databases": {
|
||||||
|
"oodb_git": {
|
||||||
|
"host": "10.10.8.83",
|
||||||
|
"port": 32100,
|
||||||
|
"database": "db",
|
||||||
|
"user": "postgres",
|
||||||
|
"password": "Root12345678"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"workspaces": {
|
||||||
|
"documents_src": {
|
||||||
|
"type": "documents",
|
||||||
|
"group": "src",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "documents_src",
|
||||||
|
"alias": "Документы исходная"
|
||||||
|
},
|
||||||
|
"documents_standard": {
|
||||||
|
"type": "documents",
|
||||||
|
"group": "order",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "documents_standard",
|
||||||
|
"alias": "Документы эталон"
|
||||||
|
},
|
||||||
|
"documents_standard_pub": {
|
||||||
|
"type": "documents",
|
||||||
|
"group": "order",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "documents_standard",
|
||||||
|
"alias": "Документы публичная"
|
||||||
|
},
|
||||||
|
"ood": {
|
||||||
|
"type": "npd",
|
||||||
|
"group": "src",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "ood",
|
||||||
|
"alias": "ООБД исходные НПД",
|
||||||
|
"map_service": "VUE_APP_GISAIS_URL:/styles/ood/style.json"
|
||||||
|
},
|
||||||
|
"oodb": {
|
||||||
|
"type": "oodb",
|
||||||
|
"group": "order",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "kartap",
|
||||||
|
"alias": "ООДБ эталон",
|
||||||
|
"map_service": "VUE_APP_GISAIS_URL:/styles/oodb/style.json"
|
||||||
|
},
|
||||||
|
"oodb_standard": {
|
||||||
|
"type": "oodb",
|
||||||
|
"group": "forming_standard",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "kartap",
|
||||||
|
"alias": "ООДБ эталон",
|
||||||
|
"map_service": "VUE_APP_GISAIS_URL:/styles/oodb/style.json"
|
||||||
|
},
|
||||||
|
"oodb_working": {
|
||||||
|
"type": "oodb",
|
||||||
|
"group": "forming_work",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "kartap",
|
||||||
|
"alias": "ООДБ рабочая",
|
||||||
|
"map_service": "VUE_APP_GISAIS_URL:/styles/oodb_tech/style.json"
|
||||||
|
},
|
||||||
|
"oodb_pub": {
|
||||||
|
"type": "oodb",
|
||||||
|
"group": "order",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "kartap",
|
||||||
|
"alias": "ООБД публичная",
|
||||||
|
"map_service": "VUE_APP_GISAIS_URL:/styles/oodb/style.json"
|
||||||
|
},
|
||||||
|
"regions": {
|
||||||
|
"type": "regions",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "regions_hard",
|
||||||
|
"alias": "Регионы",
|
||||||
|
"map_service": "VUE_APP_GISAIS_URL_GK:/styles/regions/style.json"
|
||||||
|
},
|
||||||
|
"regions_contour": {
|
||||||
|
"type": "regions",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "regions_hard",
|
||||||
|
"alias": "Регионы",
|
||||||
|
"map_service": "VUE_APP_GISAIS_URL_GK:/styles/regions_contour/style.json"
|
||||||
|
},
|
||||||
|
"npd_9": {
|
||||||
|
"type": "npd",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "npd_9",
|
||||||
|
"alias": "НПД 9.0"
|
||||||
|
},
|
||||||
|
"npd": {
|
||||||
|
"type": "npd",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "initial",
|
||||||
|
"alias": "НПД 9.0"
|
||||||
|
},
|
||||||
|
"npd_831": {
|
||||||
|
"type": "npd",
|
||||||
|
"group": "order",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "npd_831",
|
||||||
|
"alias": "НПД 8.31"
|
||||||
|
},
|
||||||
|
"updater_test": {
|
||||||
|
"type": "npd",
|
||||||
|
"group": "order",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "npd_831_test",
|
||||||
|
"alias": "НПД 8.31 публичная"
|
||||||
|
},
|
||||||
|
"lukoil": {
|
||||||
|
"type": "oodb",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "lukoil",
|
||||||
|
"alias": "ЛУКОЙЛ",
|
||||||
|
"map_service": "VUE_APP_GISAIS_URL_GK:/styles/lukoil/style.json"
|
||||||
|
},
|
||||||
|
"geocover": {
|
||||||
|
"type": "ecpz",
|
||||||
|
"group": "order",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "coverage",
|
||||||
|
"alias": "ЕЦПЗ"
|
||||||
|
},
|
||||||
|
"geocover_test": {
|
||||||
|
"type": "ecpz",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "coverage",
|
||||||
|
"alias": "ЕЦПЗ тест"
|
||||||
|
},
|
||||||
|
"gcmr": {
|
||||||
|
"type": "gcmr",
|
||||||
|
"group": "order",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "gcmr",
|
||||||
|
"alias": "ГЦМР"
|
||||||
|
},
|
||||||
|
"orders": {
|
||||||
|
"type": "system",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "orders",
|
||||||
|
"alias": "Заказы"
|
||||||
|
},
|
||||||
|
"ilo": {
|
||||||
|
"type": "system",
|
||||||
|
"database": "oodb_git",
|
||||||
|
"schema": "ilo",
|
||||||
|
"alias": "ИЛО"
|
||||||
|
},
|
||||||
|
"raz_sgok": {
|
||||||
|
"type": "raz_sgok",
|
||||||
|
"database": "razsgok",
|
||||||
|
"schema": "razsgok",
|
||||||
|
"alias": "СГОК",
|
||||||
|
"map_service": "VUE_APP_GISAIS_URL_GK:/styles/raz_sgok/style.json"
|
||||||
|
},
|
||||||
|
"raz_vtu": {
|
||||||
|
"type": "raz_vtu",
|
||||||
|
"database": "razvtu",
|
||||||
|
"schema": "razvtu",
|
||||||
|
"alias": "ВТУ",
|
||||||
|
"map_service": "VUE_APP_GISAIS_URL_GK:/styles/raz_vtu/style.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
91
main.py
91
main.py
@@ -29,6 +29,7 @@ import uvicorn
|
|||||||
from typing_extensions import Annotated
|
from typing_extensions import Annotated
|
||||||
import pathlib
|
import pathlib
|
||||||
from infra import *
|
from infra import *
|
||||||
|
from shutil import make_archive
|
||||||
|
|
||||||
|
|
||||||
NEW_REPLICATION_REQUEST = 99
|
NEW_REPLICATION_REQUEST = 99
|
||||||
@@ -672,37 +673,39 @@ def query_commits(params, files, url):
|
|||||||
|
|
||||||
|
|
||||||
def get_data(params, files, url):
|
def get_data(params, files, url):
|
||||||
|
date = datetime.datetime.now()
|
||||||
|
rxmls = RequestXmlService()
|
||||||
req = ET.fromstring(params['query_data'])
|
req = ET.fromstring(params['query_data'])
|
||||||
commit_el = req.find('commit')
|
req_id = rxmls.get_request_uuid(req)
|
||||||
commit_id = commit_el.get('id')
|
res_id = uuid4().hex
|
||||||
schema = commit_el.get('schema')
|
res = rxmls.get_request_document(res_id, req_id)
|
||||||
bnd = params['from'].replace('tcp://', '')
|
rxmls.set_result(res, 0, '')
|
||||||
|
request_string = req.find('data').text
|
||||||
|
|
||||||
con = OOConnectionParams(schema, Config.oodb_host, Config.oodb_port, Config.oodb_dbname,
|
OODBWorkspaceFactory.init('config/workspaces.json')
|
||||||
Config.oodb_username, Config.oodb_passwd, schema)
|
conf = ResponseWorkerConfig('config/response2.json', 'config/workspaces.json')
|
||||||
ws = OODBWorkspace.ws(schema)
|
worker = ResponseWorker(conf)
|
||||||
if not ws.isInit():
|
fn = uuid4().hex
|
||||||
res = ws.init(con)
|
dir = os.path.join('tmp', fn)
|
||||||
logger.warning(res)
|
os.makedirs(dir)
|
||||||
schema_commits = ws.commits(ws.branch())
|
worker.makeResponse(request_string, dir)
|
||||||
logger.warning(schema_commits)
|
make_archive(dir, 'zip', dir, '.')
|
||||||
if commit_id not in schema_commits:
|
|
||||||
logger.warning(f'Error in commits in schema {schema}: no commit {commit_id}')
|
|
||||||
return
|
|
||||||
logger.warning(schema_commits[schema_commits.index(commit_id) + 1:])
|
|
||||||
|
|
||||||
conn = db.connect_db()
|
rxmls.set_result(res, 0, '')
|
||||||
with Session(conn) as session:
|
response_params = {
|
||||||
for commit in schema_commits[schema_commits.index(commit_id) + 1:]:
|
'from': params['to'],
|
||||||
for user in session.query(db.User).filter(db.User.bndname == bnd, db.User.active == True).all():
|
'to': params['from'],
|
||||||
if user.bndname == Config.self_bnd:
|
'ts_added': date.timestamp(),
|
||||||
continue
|
'user_id': '1',
|
||||||
profiles = {x.scheme: x.to_dict() for x in user.profiles}
|
'user_id_to': params['user_id'],
|
||||||
if len(profiles) == 0 or schema in profiles:
|
'query_type': NEW_DATA_RESPONSE,
|
||||||
item = db.Queue(user_id=user.id, commit_id=commit, schema=schema)
|
'query_data': ET.tostring(res, encoding='unicode', xml_declaration=True)
|
||||||
logging.warning(item)
|
}
|
||||||
session.add(item)
|
filename = fn + '.zip'
|
||||||
session.commit()
|
filepath = os.path.join(os.getcwd(), 'tmp', filename)
|
||||||
|
response_files = [{'name': filename, 'url': filepath, 'size': os.path.getsize(filepath)}]
|
||||||
|
proxy = ServerProxy(url)
|
||||||
|
proxy.send(response_params, response_files, Config.ret_path)
|
||||||
|
|
||||||
|
|
||||||
def receive_data(params, files, url):
|
def receive_data(params, files, url):
|
||||||
@@ -926,12 +929,12 @@ def test():
|
|||||||
#get_metadata(params, files, url)
|
#get_metadata(params, files, url)
|
||||||
#get_catalog()
|
#get_catalog()
|
||||||
# auth_response('123', 'bnd127', False)
|
# auth_response('123', 'bnd127', False)
|
||||||
con = OOConnectionParams(Config.oodb_schema, Config.oodb_host, Config.oodb_port, Config.oodb_dbname,
|
# con = OOConnectionParams(Config.oodb_schema, Config.oodb_host, Config.oodb_port, Config.oodb_dbname,
|
||||||
Config.oodb_username, Config.oodb_passwd, Config.oodb_schema)
|
# Config.oodb_username, Config.oodb_passwd, Config.oodb_schema)
|
||||||
ws = OODBWorkspace.ws(Config.oodb_schema)
|
# ws = OODBWorkspace.ws(Config.oodb_schema)
|
||||||
ws.init(con)
|
# ws.init(con)
|
||||||
print(ws.currentCommit())
|
# print(ws.currentCommit())
|
||||||
print(ws.commits(ws.branch()))
|
# print(ws.commits(ws.branch()))
|
||||||
# created, updated, deleted = ws.changes('2dad8c8a-d2db-4074-ab7a-c01c36ada2be')
|
# created, updated, deleted = ws.changes('2dad8c8a-d2db-4074-ab7a-c01c36ada2be')
|
||||||
# qu = GroupQuery(Envelope())
|
# qu = GroupQuery(Envelope())
|
||||||
# qu.setUids(updated)
|
# qu.setUids(updated)
|
||||||
@@ -952,9 +955,25 @@ def test():
|
|||||||
# ws.clearData(True)
|
# ws.clearData(True)
|
||||||
# ws.close()
|
# ws.close()
|
||||||
#replication_old('bnd128', '23c9a275-ec0f-481a-8437-f3e41e4fe4f5', 'documents_src')
|
#replication_old('bnd128', '23c9a275-ec0f-481a-8437-f3e41e4fe4f5', 'documents_src')
|
||||||
|
request_string = """
|
||||||
|
{
|
||||||
|
"type": "group_query",
|
||||||
|
"data_source": "npd",
|
||||||
|
"uids": [ "2e20130c-541a-4b9f-9efb-f2a0e8b10c33" ]
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
OODBWorkspaceFactory.init('config/workspaces.json')
|
||||||
|
conf = ResponseWorkerConfig('config/response2.json', 'config/workspaces.json')
|
||||||
|
worker = ResponseWorker(conf)
|
||||||
|
fn = uuid4().hex
|
||||||
|
dir = os.path.join('tmp', fn)
|
||||||
|
os.makedirs(dir)
|
||||||
|
worker.makeResponse(request_string, dir)
|
||||||
|
make_archive(dir, 'zip', dir, '.')
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
# main()
|
||||||
# test()
|
test()
|
||||||
|
|||||||
Reference in New Issue
Block a user