本文整理汇总了Python中file.File.restore_file方法的典型用法代码示例。如果您正苦于以下问题:Python File.restore_file方法的具体用法?Python File.restore_file怎么用?Python File.restore_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file.File
的用法示例。
在下文中一共展示了File.restore_file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: store_temp_chunk
# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import restore_file [as 别名]
def store_temp_chunk(self, modification, number, path):
temp_dir = self.home + "/chunks_restore/temp/"
if not os.path.exists(temp_dir):
os.makedirs(temp_dir)
# Creates chunk
temp_dir = temp_dir.decode(system_enconding)
chunk = open(temp_dir + modification + "_" + str(number) + ".chunk", "w")
# Gets chunk body
url = self.api + "chunks/getRecover.php"
values = {"apikey": "12", "owner": self.computerId, "number": str(number), "modification": modification}
response = json_request(url, values)
if response["result"] == "ok":
chunk_body = response["chunk"]
chunk.write(chunk_body)
chunk.close()
print_message("Chunk of " + modification + " and number " + str(number) + " writed!")
else:
chunk.close()
print_message("Error getting chunk of " + modification + " and number " + str(number) + " writed!")
# Delete chunk recover
url = self.api + "chunks/deleteChunkRecover.php"
values = {"apikey": "12", "owner": self.computerId, "modification": modification, "number": str(number)}
response = json_request(url, values)
if response["result"] == "ok":
print_message("Deleted chunk recover !")
else:
print_message("Error deleting chunk recover!")
return
# Confirm chunk recover
url = self.api + "requests/confirmRecoverChunk.php"
values = {
"apikey": "12",
"computerId": self.computerId,
"modification": modification,
"chunkNumber": str(number),
}
response = json_request(url, values)
if response["result"] == "ok":
print_message("Confirmed chunk recover !")
else:
print_message("Error confirming chunk recover!")
return
# Checks if received all chunks
url = self.api + "files/restoreFileIsDone.php"
values = {"apikey": "12", "computerId": self.computerId, "modification": modification}
response = json_request(url, values)
if response["result"] == "ok":
if response["isDone"] == True:
print_message("Restore file " + path + " is done!")
f = File(self.budibox_home + path, login_box.client, modification)
f.restore_file(temp_dir, self.budibox_home + path)
global restore_requests
del restore_requests[path]
print "Feito"
示例2: get_file
# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import restore_file [as 别名]
def get_file(self, sha256, file_name,chunks):
f = File(file_name,sha256)
while(not f.restore_file(self.temp_dir, self.restore_dir,chunks)):
pass
self.remove_chunks_from_directory(f.get_file_id(), self.temp_dir)
return True