In my current situation I have a python script on my Linux server which would work on some pdf files residing on a remote windows shared folder. I am currently using smbclient to make connection to it but I am not able to work on the files, probably I need to first transfer all files to my Linux server for that which is not favorable as size of all files can be very huge. What else can I do in this situation, is there a way to create a pipeline in which python script would run and use those files to give result.
Code is as follows:
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)