miketeo/pysmb

Using same code in Windows and Linux to access remote paths

guidocioni opened this issue · 2 comments

I created a client to upload some documents on a SMB share.
As I created and tested the script under Linux I never thought of converting all the path explicit references to something not OS-dependent.
Unfortunately, I now have people running the script on Windows.
I managed to change all path references in my script using Pathlib so that they will work regardless of the system. However, as far as I understand, pysmb does not accept Pathlib object but just plain string. This means that commands like this

conn.storeFile(share_folder, folder + '/' + filename, localFile)

will fail over Windows as the SMB folder will have a different representation.

So...is there a way to re-use the same code on Windows and Linux to access a SMB share without having to write 2 different versions?

@guidocioni Please continue to use forward slashes '/' for the remote SMB paths. pysmb should handle these paths independently of the OS.

ok that's good news!