Python Forum
Access Network SMB Share on a NAS
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Access Network SMB Share on a NAS
#1
Hi there,
total NOOB here.Trying to learn some Pyhton starting from "basic" automation tasks.
What I'd like to do is telling a podcast app to update and d\l new episodes and move them to a NAS share folder. The first step is complete. What I'm having a hard time with is accessing my WD MyCloud server. I'm using Python3 on a raspberry PI 4. I've tried the following code with success to access two other shares. One is an Ubuntu machine and the other a debian antix based machine.
I can't access the NAS no way. This is the code
from smb.SMBConnection import SMBConnection

host: str = "192.160.0.8"  # ip or domain name
username = ""
password = ""
conn: SMBConnection=SMBConnection(username,password,"","",use_ntlm_v2 = False)
result = conn.connect(host, 445)


localFile=open("/home/delta/Storage/file","rb")
conn.storeFile("System4", "testfile", localFile)
localFile.close()
IF i try that code to access the NAS server I've been given the
smb.smb_structs.ProtocolError: Server does not support any of the pysmb dialects. Please email pysmb to add in support for your OS
error.
After long googleing I see the pysmb only supports SMB1\2 while my WD NAS Server should run the SMB3 version. I don't know whether that's the issue, nonetheless I've tried to use smbprotocol or smbclient, but, after installing the modules, I get a <no module named smbclient or smbprotocol> when running the script.

Hope to find some help here guys..
Reply
#2
Do you need to have your program handle the SMB interface?

It might be simpler to do an SMB mount on the pi (mount it to a filesystem), and then just access the files as local in your python program.
Reply
#3
(Oct-30-2020, 08:53 PM)bowlofred Wrote: Do you need to have your program handle the SMB interface?

It might be simpler to do an SMB mount on the pi (mount it to a filesystem), and then just access the files as local in your python program.

Well, I'd like to do that at least for learning purposes as a start.

BTW, I've managed to change the protocol version on server side switching from SMB3 to SMB2 or allowing the three of them to be accepted and the above code ends with no errors Smile . So it was definitely an issue from the protocol side. I still wonder how to handle situations accepting SMB3 only connections, but as long as you can move to SMB2, it's ok.
Thanks for your prompt reply man!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Timestamp of file changes if a share mapped to a server…. tester_V 34 3,629 Jul-04-2023, 05:19 AM
Last Post: tester_V
  access is denied error 5 for network drive mapping ? ahmedbarbary 2 1,729 Aug-17-2022, 10:09 PM
Last Post: ahmedbarbary
  access share attributed among several class methods drSlump 0 1,038 Nov-18-2021, 03:02 PM
Last Post: drSlump
  How to share a numpy array between 2 processes on Windows? qstdy 0 2,134 Jan-29-2021, 04:24 AM
Last Post: qstdy
  "could not access network location _\" MrMiyagi 0 2,019 Aug-04-2020, 06:47 PM
Last Post: MrMiyagi
  Multiprocessing share variable catosp 0 2,130 Jul-15-2020, 10:45 AM
Last Post: catosp
  SHARE PYTHON FILE ambush 1 2,831 Jan-28-2019, 04:04 AM
Last Post: snippsat
  Copy info of 2 files with share information AngelRuizM 1 2,627 Aug-14-2017, 07:31 PM
Last Post: buran
  Properly share logger objects CardBoy 2 3,125 Jun-27-2017, 08:33 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020