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


Python File.get_modification_date方法代码示例

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


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

示例1: added

# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import get_modification_date [as 别名]
    def added(self, path, client):
        path = path.replace("\\", "/")
        file_extension_pattern=self.path_to_watch+"/chunks"
        if (re.search("Thumbs.db", path) == None):
            # Checks if folder is chunks, only if it isn't it will send modifications
            if (re.search(file_extension_pattern,path) == None):
                # Prints message of file added
                print_message("Added: " + path)

                if (os.path.isfile(path)):
                    # Creates file information
                    f = File(path, client)
                    f.generate_file_id()
                    f.get_salt()
                    file_size = f.get_file_size()

                    # Gets relative_path location
                    relative_path = path.split(self.path_to_watch)[1].replace("\\", "/")
                    modification_date = f.get_modification_date().replace(" ", "T").split(".")[0] +"Z"
                    # Sends request to server with information about the new file
                    url = self.api+'files/create.php'
                    values = {'apikey': '12',
                              'path': relative_path,
                              'user': client.get_email(),
                              'modification': f.get_file_id(),
                              'dateModified': modification_date,
                              'size': str(int(file_size))
                              }
                    response = json_request(url, values)
                    if (response['result'] == 'notEnoughSpace'):
                        print_message("Not enough space. Space left to use " + str(response['spaceLeft']))
                        window = Tkinter.Tk()
                        window.wm_withdraw()

                        tkMessageBox.showerror(title="Budibox", message="Not enough space! Space left to use " + str(response['spaceLeft']) + "bytes !")
                        return

                    if (response['result'] != 'ok'):
                        print_message("Error sending information created about file " + path)
                        return

                    print_message("Created file " + path + " successfully")

                    url = self.api+'files/getId.php'
                    values = {'apikey': '12',
                              'path': relative_path,
                              'user': client.get_email(),
                              }

                    response = json_request(url, values)

                    if (response['result'] != 'ok'):
                        print_message("Error getting fileId of " + path)
                        return

                    print_message("Get fileId of " + path + "successfully")

                    # Send information about chunks to server
                    db_file_id = response['id']
                    f.generate_chunks(db_file_id)
开发者ID:hsdrose,项目名称:feup-sdis-budibox,代码行数:62,代码来源:watcher.py

示例2: send_chunks

# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import get_modification_date [as 别名]
 def send_chunks(self, path,replication_degree):
     f = File(path)
     data = Data(self.db_path)
     if (not data.get_file_id(path)):
         data.add_file(path)
     chunks_number = f.generate_chunks(self.temp_dir)
     file_id=f.generate_file_id()
     date = f.get_modification_date()
     data.add_modification(path, file_id, chunks_number, date)
     chunks=f.fetch_chunks(self.temp_dir)
     acks_chunks=0
     for j in range(len(chunks)):
         chunk_file = open(self.temp_dir +chunks[j], "rb")
         body=chunk_file.read()
         chunk_file.close()
         replication_degree=str(replication_degree)
         chunk_no=str(j)
         message="PUTCHUNK " + VERSION + " " + file_id + " " + chunk_no + " " + replication_degree + CRLF + CRLF + body
         acks=False
         attempts=0
         timeout=TIMEOUT
         while(not acks and attempts<MAX_ATTEMPTS):
             self.mdb.sendto(message, (self.mdb_address, self.mdb_port))
             data.add_chunk(file_id, chunk_no, replication_degree)
             if(self.check_replication_degree(file_id,chunk_no,replication_degree,timeout)):
                 acks=True
             timeout*=2
             attempts+=1
         if(acks): acks_chunks+=1
     self.remove_chunks_from_directory(f.get_name(),self.temp_dir)
     return (acks_chunks>=chunks_number)
开发者ID:andrefreitas,项目名称:feup-sdis-easybackups,代码行数:33,代码来源:peer.py

示例3: modified

# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import get_modification_date [as 别名]
    def modified(self, path, client):
        path = path.replace("\\", "/")
        file_extension_pattern=self.path_to_watch+"/chunks"

        if (re.search("Thumbs.db", path) == None):
            # Checks if folder is chunks, only if it isn't it will send notifications
            if (re.search(file_extension_pattern,path) != None):
                if (os.path.isfile(path)):
                    print_message("Modified in chunks path: " + path)
                    file_name = path.replace(file_extension_pattern, "")
                    modification = file_name.split("_")[0].replace("/", "")
                    chunk_number = file_name.split("_")[1].split(".")[0]
                    url = self.api+'chunks/deleted.php'
                    values = {'apikey': '12',
                              'modification': modification,
                              'number': chunk_number,
                              'computerId': self.computer_id
                              }

                    response = json_request(url, values)



                    if (response['result'] == 'ok'):
                        print_message("Deleted chunk successfully " + file_name)

                    else:
                        print_message("Error sending delete chunk message of " + file_name)
            else:
                if (os.path.isfile(path)):
                    print_message("Modified " +  path)
                    # Creates file information
                    f = File(path, client)
                    f.generate_file_id()
                    f.get_salt()
                    file_size = f.get_file_size()

                    # Gets relative_path location
                    relative_path = path.split(self.path_to_watch)[1].replace("\\", "/")
                    modification_date = f.get_modification_date().replace(" ", "T").split(".")[0] +"Z"
                    # Sends request to server with information about the new file
                    url = self.api+'files/modify.php'
                    values = {'apikey': '12',
                              'path': relative_path,
                              'user': client.get_email(),
                              'modification': f.get_file_id(),
                              'dateModified': modification_date,
                              'size': str(int(file_size))
                              }

                    response = json_request(url, values)

                    if (response['result'] == 'notEnoughSpace'):
                        print_message("Not enough space. Space left to use " + str(response['spaceLeft']))
                        window = Tkinter.Tk()
                        window.wm_withdraw()

                        tkMessageBox.showerror(title="Budibox", message="Not enough space! Space left to use " + str(response['spaceLeft']) + "bytes !")
                        return


                    if (response['result'] != 'ok'):
                        print_message("Error sending information modify about file " + path)
                        return

                    print_message("Sent modify message of: " + path)

                    url = self.api+'files/getId.php'
                    values = {'apikey': '12',
                              'path': relative_path,
                              'user': client.get_email(),
                              }

                    response = json_request(url, values)

                    if (response['result'] != 'ok'):
                        print_message("Error getting fileId of " + path)
                        return

                    # Send information about chunks to server
                    db_file_id = response['id']
                    f.generate_chunks(db_file_id)
开发者ID:hsdrose,项目名称:feup-sdis-budibox,代码行数:84,代码来源:watcher.py


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