def list_path(self, host, share, path, pattern, verbose=False, only_output=False):
'''
List shares and regex search for files in the shares to download
If only_output, will not try to download
'''
pwd = self.pathify(path)
width = 16
try:
output_file = True
pathList = self.smbconn[host].listPath(share, pwd)
if verbose:
info('\t.%s' % (path.ljust(50)))
if only_output:
if not pathList:
return []
return pathList
for item in pathList:
filesize = item.get_filesize()
readonly = 'w' if item.is_readonly() > 0 else 'r'
date = time.ctime(float(item.get_mtime_epoch()))
isDir = 'd' if item.is_directory() > 0 else 'f'
filename = item.get_longname()
if item.is_directory() <= 0:
info(pattern.lower(), filename.lower())
fileMatch = re.search(pattern.lower(), filename.lower())
if fileMatch:
dlThis = '%s\\%s/%s' % (share, ntpath.normpath(pwd.strip('*')), filename)
dlThis = dlThis.replace('/','\\')
output_file = self.download_file(host, dlThis, True)
if verbose:
info('\t%s%s--%s--%s-- %s %s\t%s' % (isDir, readonly, readonly, readonly, str(filesize).rjust(width), date, filename))
return output_file
except Exception as e:
# import traceback; traceback.print_exc()
return []
评论列表
文章目录