當前位置: 首頁>>代碼示例>>Python>>正文


Python WebService.bug_report方法代碼示例

本文整理匯總了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)
開發者ID:stoq,項目名稱:stoq,代碼行數:42,代碼來源:crashreport.py

示例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
開發者ID:pkaislan,項目名稱:stoq,代碼行數:40,代碼來源:crashreport.py


注:本文中的stoqlib.lib.webservice.WebService.bug_report方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。