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