当前位置: 首页>>代码示例>>Python>>正文


Python Common.check_for_pause方法代码示例

本文整理汇总了Python中common.Common.check_for_pause方法的典型用法代码示例。如果您正苦于以下问题:Python Common.check_for_pause方法的具体用法?Python Common.check_for_pause怎么用?Python Common.check_for_pause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common.Common的用法示例。


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

示例1: _downloader

# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import check_for_pause [as 别名]
 def _downloader(self):
     while (not self.empty()) and (not self.project.shutdown_signal):
         t = threading.current_thread()
         Common.check_for_pause(self.project)
         slip = self.get()
         if callable(slip.url):
             file_url = slip.url()
         else:
             file_url = slip.url
         t.name = "Downloading: " + slip.item[slip.filename_key]
         self.project.log("transaction", "Downloading " + slip.item[slip.filename_key], "info", True)
         try:
             data = Common.webrequest(
                 file_url, self.headers(), self.http_callback, None, False, True
             )  # Response object gets passed to shutil.copyfileobj
             self.storage_callback(data, slip)
         except urllib.error.HTTPError as err:
             self.project.log(
                 "exception",
                 "{} failed to download - HTTPError {}".format(slip.item[slip.filename_key], err.code),
                 "warning",
             )
     if self.project.shutdown_signal:
         self.project.log(
             "exception",
             "{} received shutdown signal. Stopping...".format(threading.current_thread().name),
             "warning",
         )
     else:
         self.project.log("transaction", "{} has completed.".format(threading.current_thread().name), "info")
开发者ID:jadacyrus,项目名称:searchgiant_cli,代码行数:32,代码来源:Downloader.py

示例2: _save_file

# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import check_for_pause [as 别名]
    def _save_file(self, data, slip, stream=True):
        Common.check_for_pause(self.project)
        savepath = slip.savepath

        path_to_create = os.path.dirname(savepath)  # Just the directory not the filename
        if not os.path.isdir(path_to_create):
            os.makedirs(path_to_create, exist_ok=True)

        self.project.savedata(data, savepath, stream)
        self.project.log("transaction", "Saved file to " + savepath, "info", True)
开发者ID:LucaBongiorni,项目名称:searchgiant_cli,代码行数:12,代码来源:OnlineStorage.py


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