本文整理汇总了Python中pushmanager.core.db.execute_cb函数的典型用法代码示例。如果您正苦于以下问题:Python execute_cb函数的具体用法?Python execute_cb怎么用?Python execute_cb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了execute_cb函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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,
)
示例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)
示例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'])
)
])
示例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.")
示例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
示例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'])
示例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)
示例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)
示例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]
示例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)
示例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]
示例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)
示例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)
示例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)
示例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)