data_list.py 2.1 KB
# coding=utf-8
#author:        4N
#createtime:    2021/7/19
#email:         nheweijun@sina.com

from osgeo.ogr import *
from osgeo import gdal,ogr,osr
from osgeo.gdal import Dataset,Band
from app.util.component.ApiTemplate import ApiTemplate


from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
import numpy
import cv2
import json
from .models import Image
from app.modules.image.ImageDataService import ImageDataService
from app.models import  db
import uuid
import os
import time
class Api(ApiTemplate):

    api_name = "影像数据列表"

    def process(self):


        # 返回结果
        res = {}

        try:
            data_server = self.para.get("data_server")

            path = self.para.get("path")
            host = data_server.split(":")[0]
            port = int(data_server.split(":")[1])

            # if data_server.__eq__("localhost"):
            #     pass
            # else:
            t1 =time.time()
            transport = TSocket.TSocket(host, port)
            transport = TTransport.TBufferedTransport(transport)
            protocol = TBinaryProtocol.TBinaryProtocol(transport)

            client = ImageDataService.Client(protocol)
            transport.open()
            print(time.time()-t1)
            info= json.loads(client.getImageList(path))
            res["data"] = info
            res["result"] = True

        except Exception as e:
            raise e

        return res

    api_doc = {
        "tags": ["影像接口"],
        "parameters": [
            {"name": "data_server",
             "in": "formData",
             "type": "string",
             "description": "data_server"},
            {"name": "path",
             "in": "formData",
             "type": "string",
             "description": "path"}
        ],
        "responses": {
            200: {
                "schema": {
                    "properties": {
                    }
                }
            }
        }
    }