Ejemplo n.º 1
0
 def get(self):
     try:
         self.conn = DBAction()
         self.mysql_oper = MysqlOpers(self.conn)
         ret = yield self.do()
         logging.info('ret:%s' % ret)
         records, code, msg = ret, 200, 'successful'
         self.finish(self.result(records, msg, code))
     except:
         error_msg = str(traceback.format_exc())
         logging.error(error_msg)
         records, code, msg = ret, 200, 'failed, error:%s' % error_msg
         self.finish(self.result(records, msg, code))
Ejemplo n.º 2
0
 def post(self):
     try:
         self.body = self.get_request_body()
         self.conn = DBAction()
         self.mysql_oper = MysqlOpers(self.conn)
         ret = yield self.do()
         code, records, msg = 200, [ret], 'successful'
         self.finish(self.result(records, msg, code))
     except:
         error_msg = str(traceback.format_exc())
         logging.error(error_msg)
         code, records, msg = 200, [], 'failed, error:%s' % error_msg
         self.finish(self.result(records, msg, code))
Ejemplo n.º 3
0
class MysqlSearchHandler(BaseHandler):
    executor = ThreadPoolExecutor(5)

    @asynchronous
    @coroutine
    def get(self):
        try:
            self.params = self.get_params()
            print(self.params)

            self.conn = DBAction()
            self.mysql_oper = MysqlOpers(self.conn)
            ret = yield self.do()
            logging.info('ret:%s' % ret)
            records, code, msg = ret, 200, 'successful'
            self.finish(self.result(records, msg, code))
        except:
            error_msg = str(traceback.format_exc())
            logging.error(error_msg)
            records, code, msg = ret, 200, 'failed, error:%s' % error_msg
            self.finish(self.result(records, msg, code))

    @run_on_executor
    def do(self):
        return self.mysql_oper.search(self.params)
Ejemplo n.º 4
0
class MysqlBackupHandler(BaseHandler):
    executor = ThreadPoolExecutor(5)

    @asynchronous
    @coroutine
    def post(self):
        try:
            self.body = self.get_request_body()
            uuid = self.body.get('uuid')
            self.conn = DBAction()
            self.mysql_oper = MysqlOpers(self.conn)
            yield self.do(uuid)
            code, records, msg = 200, [uuid], 'successful'
            self.finish(self.result(records, msg, code))
        except:
            error_msg = str(traceback.format_exc())
            logging.error(error_msg)
            code, records, msg = 200, [uuid], 'failed, error:%s' % error_msg
            self.finish(self.result(records, msg, code))

    @run_on_executor
    def do(self, uuid):
        self.mysql_oper.backup(uuid)
Ejemplo n.º 5
0
class MysqlContainerInstallHandler(BaseHandler):
    executor = ThreadPoolExecutor(5)

    @asynchronous
    @coroutine
    def post(self):
        try:
            self.body = self.get_request_body()
            self.conn = DBAction()
            self.mysql_oper = MysqlOpers(self.conn)
            ret = yield self.do()
            code, records, msg = 200, [ret], 'successful'
            self.finish(self.result(records, msg, code))
        except:
            error_msg = str(traceback.format_exc())
            logging.error(error_msg)
            code, records, msg = 200, [], 'failed, error:%s' % error_msg
            self.finish(self.result(records, msg, code))

    @run_on_executor
    def do(self):
        return self.mysql_oper.install_container(self.body)