• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python db.execute_cb函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pushmanager.core.db.execute_cb函数的典型用法代码示例。如果您正苦于以下问题:Python execute_cb函数的具体用法?Python execute_cb怎么用?Python execute_cb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了execute_cb函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: post

    def post(self):
        if not self.current_user:
            return self.send_error(403)

        push_id = self.request.arguments.get("id", [None])[0]
        if not push_id:
            return self.send_error(404)
        contents_query = self.generate_pushcontent_query(push_id)
        db.execute_cb(contents_query, self.get_push_request_users)
        people = self.people
        message = self.request.arguments.get("message", [None])[0]
        if not message:
            return self.send_error(500)

        irc_nick = Settings["irc"]["nickname"].format(pushmaster=self.current_user)

        if not people:
            irc_message = u"[[pushmaster {0}]] {1}".format(self.current_user, message)

            subprocess.call(["/nail/sys/bin/nodebot", "-i", irc_nick, Settings["irc"]["channel"], irc_message])
            return

        send_people_msg_in_groups(
            people,
            message,
            irc_nick,
            Settings["irc"]["channel"],
            person_per_group=5,
            prefix_msg="[[pushmaster %s]]" % self.current_user,
        )
开发者ID:YelpArchive,项目名称:pushmanager,代码行数:30,代码来源:msg.py


示例2: get

    def get(self):
        pushid = pushmanager.core.util.get_int_arg(self.request, 'push')
        ping_action = pushmanager.core.util.get_str_arg(self.request, 'action')
        response = yield tornado.gen.Task(
                        self.async_api_call,
                        "push",
                        {"id": pushid}
                    )

        push = self.get_api_results(response)
        if not push:
            self.send_error()

        pings = set(x for x in (push['extra_pings'] or "").split(',') if x)
        if ping_action == 'set':
            pings.add(self.current_user)
        else:
            pings.discard(self.current_user)

        # This is not atomic, so we could theoretically
        # run into race conditions here, but since we're
        # working at machine speed on human input triggers
        # it should be okay for now.
        query = db.push_pushes.update().where(
            db.push_pushes.c.id == pushid,
        ).values({
            'extra_pings': ','.join(pings),
        })
        db.execute_cb(query, self.on_update_complete)
开发者ID:Mango-J,项目名称:pushmanager,代码行数:29,代码来源:pingme.py


示例3: test_update_req_sha_and_queue_pickme_added_test_conflicting_pickmes

    def test_update_req_sha_and_queue_pickme_added_test_conflicting_pickmes(self):
        new_sha = "1"*40
        pickme_request = copy.deepcopy(self.fake_request)
        pickme_request['state'] = 'added'
        pickme_request['tags'] = 'conflict-pickme'
        with mock.patch('pushmanager.core.git.GitQueue.enqueue_request') as enqueue_req:
            with mock.patch.dict(Settings, MockedSettings):
                GitQueue._update_req_sha_and_queue_pickme(pickme_request, new_sha)

                result = [None]

                def on_db_return(success, db_results):
                    assert success, "Database error"
                    result[0] = db_results.first()

                request_info_query = db.push_requests.select().where(
                    db.push_requests.c.id == self.fake_request['id']
                )
                db.execute_cb(request_info_query, on_db_return)
                T.assert_equal(result[0][5], new_sha)
                T.assert_equals(enqueue_req.call_count, 2)
                enqueue_req.assert_has_calls([
                    mock.call(
                        GitTaskAction.TEST_CONFLICTING_PICKMES,
                        GitQueue._get_push_for_request(pickme_request['id'])['push'],
                        pushmanager_url='https://%s:%s' % (
                            MockedSettings['main_app']['servername'],
                            MockedSettings['main_app']['port'])
                        )
                ])
开发者ID:Mango-J,项目名称:pushmanager,代码行数:30,代码来源:test_core_git.py


示例4: test_removerequest

    def test_removerequest(self):
        results = []

        def on_db_return(success, db_results):
            assert success
            results.extend(db_results.fetchall())

        with nested(
            mock.patch.dict(db.Settings, MockedSettings),
            mock.patch.object(
                RemoveRequestServlet,
                "get_current_user",
                return_value="testuser"
            )
        ):
            results = []
            db.execute_cb(db.push_pushcontents.select(), on_db_return)
            num_results_before = len(results)

            uri = "/removerequest?request=1&push=1"
            response = self.fetch(uri)
            T.assert_equal(response.error, None)

            results = []
            db.execute_cb(db.push_pushcontents.select(), on_db_return)
            num_results_after = len(results)

            T.assert_equal(num_results_after, num_results_before - 1, "Request removal failed.")
开发者ID:Mango-J,项目名称:pushmanager,代码行数:28,代码来源:test_servlet_removerequest.py


示例5: assert_submit_request

    def assert_submit_request(self, request, edit=False, redirect=None):
        results = []

        def on_db_return(success, db_results):
            assert success
            results.extend(db_results.fetchall())

        results = []
        db.execute_cb(db.push_requests.select(), on_db_return)
        num_results_before = len(results)

        if redirect:
            with mock.patch.object(NewRequestServlet, "redirect") as redir:
                response = self.fetch("/newrequest", method="POST", body=urllib.urlencode(request))
                T.assert_equal(response.error, None)

                T.assert_equal(redir.call_args[0][0], redirect)
        else:
            response = self.fetch("/newrequest", method="POST", body=urllib.urlencode(request))
            T.assert_equal(response.error, None)

        results = []
        db.execute_cb(db.push_requests.select(), on_db_return)
        num_results_after = len(results)

        if not edit:
            T.assert_equal(num_results_after, num_results_before + 1)

            last_req = self.get_requests()[-1]
            T.assert_equal(len(results), last_req["id"])
            return last_req
        else:
            T.assert_equal(num_results_after, num_results_before)
            last_req = self.get_requests()[-1]
            return last_req
开发者ID:rschlaikjer,项目名称:pushmanager,代码行数:35,代码来源:test_servlet_newrequest.py


示例6: test_removed_trailing_whitespace_in_branch_name

    def test_removed_trailing_whitespace_in_branch_name(self):
        def on_db_return(success, db_results):
            assert success
            pushes.extend(db_results.fetchall())

        with nested(
            mock.patch.dict(db.Settings, MockedSettings),
            mock.patch.object(NewPushServlet, "get_current_user", return_value="jblack"),
            mock.patch.object(NewPushServlet, "redirect"),
            mock.patch.object(MailQueue, "enqueue_user_email"),
        ):
            with mock.patch("%s.pushmanager.servlets.newpush.subprocess.call" % __name__):
                title = "BestPushInTheWorld"
                branch = "%20branch-name-with-whitespaces%20"
                push_type = "regular"

                self.fetch(
                    "/newpush?push-title=%s&push-branch=%s&push-type=%s" % (
                        title, branch, push_type
                    )
                )

                pushes = []
                db.execute_cb(db.push_pushes.select(), on_db_return)
                T.assert_equal('branch-name-with-whitespaces', pushes[-1]['branch'])
开发者ID:Mango-J,项目名称:pushmanager,代码行数:25,代码来源:test_servlet_newpush.py


示例7: post

    def post(self):
        if not self.current_user:
            return self.send_error(403)
        self.requestid = self._arg('request-id')
        self.tag_list = [x for x in TAGS_RE.findall(self._arg('request-tags')) if x and 'conflict' not in x]

        reviewid = self._arg('request-review')
        if reviewid:
            try:
                reviewid = int(reviewid)
            except (ValueError, TypeError):
                return self.send_error(500)

        watchers = ','.join(map(str.strip, self._arg('request-watchers').split(',')))

        if self.requestid != '':
            self.requestid = int(self.requestid)

            updated_values = {
                    'title': self._arg('request-title'),
                    'tags': ','.join(self.tag_list),
                    'reviewid': reviewid or None,
                    'repo': self._arg('request-repo').strip(),
                    'branch': self._arg('request-branch').strip(),
                    'comments': self._arg('request-comments'),
                    'description': self._arg('request-description'),
                    'watchers': watchers,
                    'modified': time.time(),
                    'revision': '0'*40,
            }

            if len(self._arg('request-takeover')):
                updated_values.update({'user': self.current_user})
                self.request_user = self.current_user
            else:
                self.request_user = self._arg('request-user')

            query = db.push_requests.update().where(
                    db.push_requests.c.id == self.requestid
                ).values(updated_values)
        else:
            query = db.push_requests.insert({
                'title': self._arg('request-title'),
                'user': self.current_user,
                'tags': ','.join(self.tag_list),
                'reviewid': self._arg('request-review') or None,
                'repo': self._arg('request-repo').strip(),
                'branch': self._arg('request-branch').strip(),
                'comments': self._arg('request-comments'),
                'description': self._arg('request-description'),
                'watchers': watchers,
                'created': time.time(),
                'modified': time.time(),
                'state': 'requested',
                'revision': '0'*40,
                })
            self.request_user = self.current_user

        db.execute_cb(query, self.on_request_upsert_complete)
开发者ID:dyakovlev,项目名称:pushmanager,代码行数:59,代码来源:newrequest.py


示例8: _api_PUSH

    def _api_PUSH(self):
        """Returns a JSON representation of a push."""
        push_id = util.get_int_arg(self.request, 'id')
        if not push_id:
            return self.send_error(404)

        query = db.push_pushes.select(db.push_pushes.c.id == push_id)
        db.execute_cb(query, self._on_PUSH_db_response)
开发者ID:Mango-J,项目名称:pushmanager,代码行数:8,代码来源:api.py


示例9: get_requests

    def get_requests(self):
        requests = [None]
        def on_select_return(success, db_results):
            assert success
            requests[0] = db_results.fetchall()

        db.execute_cb(db.push_requests.select(), on_select_return)
        return requests[0]
开发者ID:dyakovlev,项目名称:pushmanager,代码行数:8,代码来源:testdb.py


示例10: _api_REQUEST

    def _api_REQUEST(self):
        """Returns a JSON representation of a push request."""
        request_id = util.get_int_arg(self.request, 'id')
        if not request_id:
            return self.send_error(404)

        query = db.push_requests.select(db.push_requests.c.id == request_id)
        db.execute_cb(query, self._on_REQUEST_db_response)
开发者ID:Mango-J,项目名称:pushmanager,代码行数:8,代码来源:api.py


示例11: get_pushes

    def get_pushes(self):
        pushes = [None]
        def on_select_return(success, db_results):
            assert success
            pushes[0] = db_results.fetchall()

        db.execute_cb(db.push_pushes.select(), on_select_return)
        return pushes[0]
开发者ID:dyakovlev,项目名称:pushmanager,代码行数:8,代码来源:testdb.py


示例12: on_request_upsert_complete

    def on_request_upsert_complete(self, success, db_results):
        self.check_db_results(success, db_results)

        if not self.requestid:
            self.requestid = db_results.lastrowid

        query = db.push_checklist.select().where(db.push_checklist.c.request == self.requestid)
        db.execute_cb(query, self.on_existing_checklist_retrieved)
开发者ID:dyakovlev,项目名称:pushmanager,代码行数:8,代码来源:newrequest.py


示例13: post

    def post(self):
        if not self.current_user:
            return self.send_error(403)

        self.pushid = pushmanager.core.util.get_int_arg(self.request, 'push')
        self.request_ids = self.request.arguments.get('request', [])

        db.execute_cb(db.push_pushes.select().where(db.push_pushes.c.id == self.pushid), self.on_push_select)
开发者ID:eevee,项目名称:pushmanager,代码行数:8,代码来源:pickmerequest.py


示例14: post

    def post(self):
        if not self.current_user:
            return self.send_error(403)

        self.checklist = pushmanager.core.util.get_int_arg(self.request, 'id')
        new_value = pushmanager.core.util.get_int_arg(self.request, 'complete')

        query = db.push_checklist.update().where(
            db.push_checklist.c.id == self.checklist).values({'complete': new_value})
        db.execute_cb(query, lambda _, __:None)
开发者ID:eevee,项目名称:pushmanager,代码行数:10,代码来源:checklist.py


示例15: _api_PUSHCONTENTS

    def _api_PUSHCONTENTS(self):
        """Returns a set of JSON representations of requests in a given push."""
        push_id = util.get_int_arg(self.request, 'id')
        if not push_id:
            return self.send_error(404)

        query = db.push_requests.select(SA.and_(
            db.push_requests.c.id == db.push_pushcontents.c.request,
            db.push_pushcontents.c.push == push_id,
        ))
        db.execute_cb(query, self._on_PUSHCONTENTS_db_response)
开发者ID:Mango-J,项目名称:pushmanager,代码行数:11,代码来源:api.py


示例16: post

    def post(self):
        if not self.current_user:
            return self.send_error(403)

        self.checklist = pushmanager.core.util.get_int_arg(self.request, "id")
        new_value = pushmanager.core.util.get_int_arg(self.request, "complete")

        query = (
            db.push_checklist.update().where(db.push_checklist.c.id == self.checklist).values({"complete": new_value})
        )
        db.execute_cb(query, lambda _, __: self.finish())
开发者ID:rschlaikjer,项目名称:pushmanager,代码行数:11,代码来源:checklist.py


示例17: _api_PUSHBYREQUEST

    def _api_PUSHBYREQUEST(self):
        """Returns a JSON representation of a PUSH given a request id."""
        request_id = util.get_int_arg(self.request, 'id')
        if not request_id:
            return self.send_error(404)

        query = db.push_pushes.select(SA.and_(
            db.push_pushes.c.state != "discarded",
            db.push_pushcontents.c.push == db.push_pushes.c.id,
            db.push_pushcontents.c.request == request_id,
        ))
        db.execute_cb(query, self._on_PUSHBYREQUEST_db_response)
开发者ID:Mango-J,项目名称:pushmanager,代码行数:12,代码来源:api.py


示例18: get_push_for_request

    def get_push_for_request(self, requestid):
        pushid = [None]
        def on_select_return(success, db_results):
            assert success
            _, pushid[0] = db_results.fetchone()

        # check if we have a push in with request
        first_pushcontent_query = db.push_pushcontents.select(
            db.push_pushcontents.c.request == requestid
        )
        db.execute_cb(first_pushcontent_query, on_select_return)
        return pushid[0]
开发者ID:dyakovlev,项目名称:pushmanager,代码行数:12,代码来源:testdb.py


示例19: get_checklists

    def get_checklists(self, requestid):
        checklists = list()
        def on_select_return(success, db_results):
            assert success
            for cl in db_results.fetchall():
                # id, *request*, *type*, complete, *target*
                checklists.append((cl[1], cl[2], cl[4]))

        select_query = db.push_checklist.select().where(
                db.push_checklist.c.request == requestid)

        db.execute_cb(select_query, on_select_return)

        return checklists
开发者ID:eevee,项目名称:pushmanager,代码行数:14,代码来源:test_servlet_newrequest.py


示例20: get

 def get(self):
     query = db.push_pushes.select(SA.and_(
                     db.push_pushes.c.state == 'accepting',
                     SA.exists([1],
                         SA.and_(
                             db.push_pushcontents.c.push == db.push_pushes.c.id,
                             db.push_pushcontents.c.request == db.push_requests.c.id,
                             db.push_requests.c.user == self.current_user,
                         ),
                     ),
                 ),
                 order_by=db.push_pushes.c.created.asc(),
             )
     db.execute_cb(query, self.on_db_response)
开发者ID:hashbrowncipher,项目名称:pushmanager,代码行数:14,代码来源:smartdest.py



注:本文中的pushmanager.core.db.execute_cb函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python db.execute_transaction_cb函数代码示例发布时间:2022-05-25
下一篇:
Python pusher.Pusher类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap