本文整理汇总了Python中file.File.get_salt方法的典型用法代码示例。如果您正苦于以下问题:Python File.get_salt方法的具体用法?Python File.get_salt怎么用?Python File.get_salt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file.File
的用法示例。
在下文中一共展示了File.get_salt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: added
# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import get_salt [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: modified
# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import get_salt [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)