本文整理汇总了Python中stoqlib.lib.webservice.WebService.bug_report方法的典型用法代码示例。如果您正苦于以下问题:Python WebService.bug_report方法的具体用法?Python WebService.bug_report怎么用?Python WebService.bug_report使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.lib.webservice.WebService
的用法示例。
在下文中一共展示了WebService.bug_report方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ReportSubmitter
# 需要导入模块: from stoqlib.lib.webservice import WebService [as 别名]
# 或者: from stoqlib.lib.webservice.WebService import bug_report [as 别名]
class ReportSubmitter(gobject.GObject):
gsignal("failed", object)
gsignal("submitted", object)
def __init__(self):
gobject.GObject.__init__(self)
self._count = 0
self._api = WebService()
self.report = collect_report()
def _done(self, args):
self.emit("submitted", args)
def _error(self, args):
self.emit("failed", args)
def submit(self):
return self._api.bug_report(self.report, callback=self._on_report__callback, errback=self._on_report__errback)
def _on_report__callback(self, response):
if response.status_code == 200:
self._on_success(response.json())
else:
self._on_error()
def _on_report__errback(self, failure):
self._on_error(failure)
def _on_error(self, data=None):
log.info("Failed to report bug: %r count=%d" % (data, self._count))
if self._count < _N_TRIES:
self.submit()
else:
schedule_in_main_thread(self.emit, "failed", data)
self._count += 1
def _on_success(self, data):
log.info("Finished sending bugreport: %r" % (data,))
schedule_in_main_thread(self.emit, "submitted", data)
示例2: ReportSubmitter
# 需要导入模块: from stoqlib.lib.webservice import WebService [as 别名]
# 或者: from stoqlib.lib.webservice.WebService import bug_report [as 别名]
class ReportSubmitter(gobject.GObject):
gsignal("failed", object)
gsignal("submitted", object)
def __init__(self):
gobject.GObject.__init__(self)
self._api = WebService()
self._report = collect_report()
self._count = 0
def _done(self, args):
self.emit("submitted", args)
def _error(self, args):
self.emit("failed", args)
@property
def report(self):
return self._report
def submit(self):
response = self._api.bug_report(self._report)
response.addCallback(self._on_report__callback)
response.addErrback(self._on_report__errback)
return response
def _on_report__callback(self, data):
log.info("Finished sending bugreport: %r" % (data,))
self._done(data)
def _on_report__errback(self, failure):
log.info("Failed to report bug: %r count=%d" % (failure, self._count))
if self._count < _N_TRIES:
self.submit()
else:
self._error(failure)
self._count += 1