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


Python File.restore_file方法代码示例

本文整理汇总了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"
开发者ID:hsdrose,项目名称:feup-sdis-budibox,代码行数:71,代码来源:client_daemon.py

示例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
开发者ID:andrefreitas,项目名称:feup-sdis-easybackups,代码行数:8,代码来源:peer.py


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