#!/usr/bin/env python
# -*- coding: utf-8 -*-
from services.service import ServiceService
import tornado.web
import tornado.gen
import tornado.escape
import json
from util.rabbitmq import send_message
from stormed import Message
import settings

    
class GitLabOAuthHandler(tornado.web.RequestHandler):
    s_oauth = OAuthService()
    
    @tornado.web.asynchronous
    @tornado.gen.engine
    def post(self):
        spec_type = self.get_argument("spec_type","name")
        spec_text =  self.get_argument("spec_text","")
        page_index =int(self.get_argument("page_index",0))
        page_size =int(self.get_argument("page_size",20))
        spec ={}
        spec[spec_type]={ '$regex' : spec_text}
        fields={
            "name":True,
            "user":True,
            "image":True,
            "code":True,
            "status":True,
            "logs":True,
            "update_time":True,
            'create_time':True
        }

        services =yield tornado.gen.Task(self.s_service.get_list,spec,fields=fields,page_index=page_index,page_size=page_size)
        _json = ""
        if not services:
            _json =json.dumps({"status":"error","error_code":404})
        else:
            _json = json.dumps({"status":"success","data":services})
        self.write(_json)
        self.finish()

@@ -57,23 +57,20 @@
 ces.
+u
 ser
-vice
  import 
 Serv
@@ -65,23 +65,20 @@
  import 
-Service
+User
 Service%0A
@@ -232,21 +232,51 @@
 ettings%0A
-%0A    
+from views import AsyncBashHandler%0A
 %0Aclass G
@@ -297,27 +297,17 @@
 ler(
-tornado.web.Request
+AsyncBash
 Hand
@@ -350,38 +350,8 @@
    %0A
-    @tornado.web.asynchronous%0A
     
@@ -382,12 +382,14 @@
 def 
+_
 post
+_
 (sel
@@ -404,78 +404,22 @@
     
-spec_type = self.get_argument(%22spec_type%22,%22name%22)%0A        spec_text
+access_token
  =
- 
  sel
@@ -437,438 +437,131 @@
 ent(
-%22spec_text%22,%22%22)%0A        page_index =int(self.get_argument(%22page_index%22,0))%0A        page_size =int(self.get_argument(%22page_size%22,20))%0A        spec =%7B%7D%0A        spec%5Bspec_type%5D=%7B '$regex' : spec_text%7D%0A        fields=%7B%0A            %22name%22:True,%0A            %22user%22:True,%0A            %22image%22:True,%0A            %22code%22:True,%0A            %22status%22:True,%0A            %22logs%22:True,%0A            %22update_time%22:True,%0A            'create_time':True
+'access_token')%0A        gitlab_user = self.get_argument('user')%0A        current_user = self.current_user.get('_id','admin')
 %0A   
@@ -569,10 +569,8 @@
     
-%7D%0A
 %0A   
@@ -578,18 +578,15 @@
     
+u
 ser
-vices
  =
+ 
 yiel
@@ -615,325 +615,35 @@
 f.s_
-service.get_list,spec,fields=fields,page_index=page_index,page_size=page_size)%0A        _json = %22%22%0A        if not services:%0A            _json =json.dumps(%7B%22status%22:%22error%22,%22error_code%22:404%7D)%0A        else:%0A            _json = json.dumps(%7B%22status%22:%22success%22,%22data%22:services%7D)%0A        self.write(_json)%0A        self.finish(
+oauth.update,current_user,%7B%7D 
 )%0A

Update oauth.py