本文整理汇总了Python中pyasm.biz.File.get_md5方法的典型用法代码示例。如果您正苦于以下问题:Python File.get_md5方法的具体用法?Python File.get_md5怎么用?Python File.get_md5使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.biz.File
的用法示例。
在下文中一共展示了File.get_md5方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_system_commands
# 需要导入模块: from pyasm.biz import File [as 别名]
# 或者: from pyasm.biz.File import get_md5 [as 别名]
def handle_system_commands(my, snapshot, files, file_objects, mode, md5s, source_paths=[], file_sizes=[]):
'''move the tmp files in the appropriate directory'''
# if mode is local then nothing happens here
if mode == 'local':
return
sobject = snapshot.get_sobject()
# inplace mode does not move the file. It just registers the file
# object
if mode == 'inplace':
for i, file in enumerate(files):
file_object = file_objects[i]
to_name = file_object.get_full_file_name()
to_path = file
# This is handled in create_file_types
#file_type = snapshot.get_type_by_file_name(to_name)
#file_object.set_value('type', file_type)
if not os.path.isdir(to_path):
md5_checksum = None
if md5s:
md5_checksum = md5s[i]
if not md5_checksum:
md5_checksum = File.get_md5(to_path)
if md5_checksum:
file_object.set_value("md5", md5_checksum)
file_object.commit(triggers=False)
return
for i, file in enumerate(files):
file_object = file_objects[i]
to_name = file_object.get_full_file_name()
file_type = snapshot.get_type_by_file_name(to_name)
lib_dir = snapshot.get_lib_dir(file_type=file_type, file_object=file_object)
# it should have been created in postprocess_snapshot
System().makedirs(lib_dir)
to_path = "%s/%s" % (lib_dir, to_name )
#print "path: ", i, files[i]
#print to_path, os.path.exists(to_path)
# first make sure that the to path does not exist, if so, just skip
if os.path.exists(to_path) and mode not in ['inplace','preallocate']:
raise CheckinException('This path [%s] already exists'%to_path)
# add the file
try:
# inplace undo used to not touch the file,
# now it will be moved to cache on undo
io_action = True
if mode in ['preallocate']:
io_action = False
if mode == 'move':
FileUndo.move( source_paths[i], to_path )
#elif mode == 'copy': # was free_copy
#FileUndo.create( source_paths[i], to_path, io_action=io_action )
# make it look like the files was created in the repository
else: # mode ='create'
md5 = file_object.get_value("md5")
st_size = file_object.get_value("st_size")
rel_dir = file_object.get_value("relative_dir")
if mode == 'copy':
io_action = 'copy'
src_path = source_paths[i]
else:
src_path = files[i]
file_name = to_name
rel_path = "%s/%s" % (rel_dir, file_name)
FileUndo.create( src_path, to_path, io_action=io_action, extra={ "md5": md5, "st_size": st_size, "rel_path": rel_path } )
except IOError, e:
raise CheckinException('IO Error occurred. %s' %e.__str__())
# check to see that the file exists.
if not os.path.exists( to_path ):
if mode in ["inplace", "preallocate"]:
raise CheckinException("File not found in repo at [%s]" % to_path )
else:
raise CheckinException("Failed move [%s] to [%s]" % \
(files[i], to_path) )
#.........这里部分代码省略.........