Fix downloading file from enserver
This commit is contained in:
15
main.py
15
main.py
@@ -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
|
||||
@@ -539,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)
|
||||
@@ -560,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):
|
||||
|
||||
Reference in New Issue
Block a user