本文整理汇总了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")
示例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)