Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Python SMB Connection
-
@DavinE could you try with my module
SMB_client.pyand
from SMB_client import SMB_client my_smb = SMB_client(username='admin',password='admin',smb_name='share') my_smb.connect() tree = my_smb.getRemoteTree() for elem in tree: print(elem)
-
@cvp said:
@DavinE could you try with my module
SMB_client.pyand
from SMB_client import SMB_client my_smb = SMB_client(username='admin',password='admin',smb_name='share') my_smb.connect() tree = my_smb.getRemoteTree() for elem in tree: print(elem)
yeah i tried it but i can retry it...
i do not have
SMB_client
installed
should i install it ? and try -
@DavinE did you see the link in my post?
-
-
@cvp said:
@DavinE did you see the link in my post?
yeah sry, that's my mistake....
i get this output:
Error on line 47 TypeError 'NoneType' object is not subscriptable Error on line 62 TypeError str, bytes or bytearray expected, not NoneType Error on line 87 NotReadyError SMB connection not authenticated
-
@DavinE strange, I'll check, my smb connection works
-
-
@DavinE could you try, with your own user, pwd, server
from SMB_client import SMB_client import keychain server_ftp = 'VOO-USB' user = 'voo' # get password from keychain pwd = keychain.get_password(server_ftp,user) my_smb = SMB_client(username=user,password=pwd, smb_name='VOO-USB', print_errors=False) my_smb.connect() print(my_smb.getRemoteDir('', '*'))
-
smb_files = my_smb.getRemoteDir('', '*') for smb_file in smb_files: smb_filename = smb_file.filename print(smb_file.filename)
-
@cvp said:
@DavinE could you try, with your own user, pwd, server
from SMB_client import SMB_client import keychain server_ftp = 'VOO-USB' user = 'voo' # get password from keychain pwd = keychain.get_password(server_ftp,user) my_smb = SMB_client(username=user,password=pwd, smb_name='VOO-USB', print_errors=False) my_smb.connect() print(my_smb.getRemoteDir('', '*'))
i get
None
but is it correct that i set my pass in
server_ftp
-
@DavinE said:
but is it correct that i set my pass in server_ftp
Forget my keychain process. In all my scripts, I store my passwords in keychain.
Use your username='xxx',password='xxx',smb_name='xxx' -
@DavinE and put your ip as server (my server has an ip but also a name)
-
@cvp
sry.... i'm confused....smb_name = "" # That is my Folder share name or ??
and where i need to put my Server ip ?i have this:
my_smb = SMB_client(username=user,password=pwd, smb_name='home', print_errors=False)
-
@DavinE this should be ok if you know the ip but not the smb name
ip = .... my_smb = SMB_client() smb_name = my_smb.getBIOSName(ip) print(smb_name) my_smb = SMB_client(username=user,password=pwd, smb_name=smb_name, print_errors=False) my_smb.connect() smb_files = my_smb.getRemoteDir('', '*') for smb_file in smb_files: smb_filename = smb_file.filename print(smb_file.filename)
-
-
-
@DavinE said:
Here i get None
I you used my last post, that would say the ip is not correct.
The first my_smb is used to get the smb_name from the ip and the second uses the smb_name.I print the smb_name, do you see it?
-
Now, this should work if you know the ip
from SMB_client import SMB_client ip = 'xxx.xxx.xxx.xxx' user = 'xxxxxx' pwd = 'xxxxx' my_smb = SMB_client() smb_name = my_smb.getBIOSName(ip) print('smb_name=',smb_name) my_smb = SMB_client(username=user,password=pwd, smb_name=smb_name, print_errors=False) my_smb.connect() smb_files = my_smb.getRemoteDir('', '*') for smb_file in smb_files: smb_filename = smb_file.filename print(smb_file.filename)
-
@cvp said:
Now, this should work if you know the ip
from SMB_client import SMB_client ip = 'xxx.xxx.xxx.xxx' user = 'xxxxxx' pwd = 'xxxxx' my_smb = SMB_client() smb_name = my_smb.getBIOSName(ip) print('smb_name=',smb_name) my_smb = SMB_client(username=user,password=pwd, smb_name=smb_name, print_errors=False) my_smb.connect() smb_files = my_smb.getRemoteDir('', '*') for smb_file in smb_files: smb_filename = smb_file.filename print(smb_file.filename)
so i tried it with my Raspberry Pi2....
here is my output:pi@RaspberryPi2:~/TEST/smb $ python smb_de.py ('smb_name=', 'ELEKTROTECHNIK') . .. Drive
on my iPad pro 12.9" i get only:
smb_name=, ELEKTROTECHNIK
with the same user and pwd....
this is a iPad problem or ? -
@cvp said:
my_smb = SMB_client()
smb_name = my_smb.getBIOSName(ip)
print('smb_name=',smb_name)These lines do not use user nor pwd, it is only to get the smb_name that you need to use in tHe second. Note that if you know this smb_name, the ip is not necessary
my_smb = SMB_client(username=user,password=pwd, smb_name=smb_name, print_errors=False) my_smb.connect() smb_files = my_smb.getRemoteDir('', '*') for smb_file in smb_files: smb_filename = smb_file.filename print(smb_file.filename)