在我目前的情况下,我的Linux服务器上有一个python脚本,可以处理远程windows共享文件夹中的一些pdf文件。我目前正在使用smbclient连接到它,但我无法处理文件,可能我需要首先将所有文件传输到我的Linux服务器,因为所有文件的大小都可能非常大。在这种情况下,我还能做什么呢?有没有一种方法可以创建一个管道,让python脚本在其中运行,并使用这些文件给出结果。你知道吗
代码如下:from smb.SMBConnection import SMBConnection
userID = '---------'
password = '-------'
client_machine_name = '-----'
server_name = ' '
server_ip = '...'
domain_name = '-------'
conn=SMBConnection(userID,password, client_machine_name, server_name,
domain=domain_name, use_ntlm_v2=True,is_direct_tcp=True)
conn.connect(server_ip, 445)
shares = conn.listShares()
# storing file names in a list
dirlist = []
for share in shares:
if not share.isSpecial and share.name not in ['NETLOGON', 'SYSVOL']:
sharedfiles = conn.listPath(share.name, '/DMDA_2.0_Files/ProcessedBatchDocPdfs/12345678')
for sharedfile in sharedfiles:
print(sharedfile.filename)
dirlist.append(sharedfile.filename)
# retrieve or download file
path = 'DMDA_2.0_Files/ProcessedBatchDocPdfs/12345678/111111.pdf'
with open('abc.pdf','wb') as f:
conn.retrieveFile(share.name, path, f)