miketeo / pysmb

pysmb is an experimental SMB/CIFS library written in Python. It implements the client-side SMB/CIFS protocol (SMB1 and SMB2) which allows your Python application to access and transfer files to/from SMB/CIFS shared folders like your Windows file sharing and Samba folders.
Other
338 stars 95 forks source link

Unable to connect via python3 #55

Open sho-suzuki opened 8 years ago

sho-suzuki commented 8 years ago

I use pysmb 1.1.8 and python 2.7.9, 3.4.3 In python 2.7.9, it can connect to the smb server. but in python3.4.3, can't access smb server.

code andtrace back as follows:

    def _smb_connect(self):
        self.conn = SMBConnection(self.userID, self.password, self.client_machine_name, self.server_name, self.domain, use_ntlm_v2=True)
        assert self.conn.connect(self.server_ip, 139)
        remote_filelist = self.conn.listPath(service_name=self.rootdir, path=self.logpath, pattern=u"*")  ```

```python:traceback
Traceback
  File "/usr/local/pyenv/versions/devel-3.4.3/lib/python3.4/site-packages/smb/base.py", line 651, in connectCB
    errback(OperationFailure('Failed to list %s on %s: Unable to connect to shared device' % ( path, service_name ), messages_history))
  File "/usr/local/pyenv/versions/devel-3.4.3/lib/python3.4/site-packages/smb/SMBConnection.py", line 178, in eb
    raise failure
smb.smb_structs.OperationFailure: Failed to list サブディレクトリ on mydir: Unable to connect to shared device
==================== SMB Message 0 ====================
SMB Header:
-----------
Command: 0x03 (SMB2_COM_TREE_CONNECT)
Status: 0x00000000
Flags: 0x08
PID: 31223
MID: 3
TID: 0
Data: 46 bytes
b'0900000---6800'
SMB Data Packet (hex):
----------------------
b'fe534d4240000000---63006800'
==================== SMB Message 1 ====================
SMB Header:
-----------
Command: 0x03 (SMB2_COM_TREE_CONNECT)
Status: 0xC0000022
Flags: 0x09
PID: 31223
MID: 3
TID: 0
Data: 9 bytes
b'09000000000000005c'
SMB Data Packet (hex):
----------------------
b'fe534d4240000000----000000000000005c'

I feel like a problem due to the conversion of the character code.

JinWuZhao commented 8 years ago

I meet this problem, too. This is the code: director = urllib.request.build_opener(SMBHandler) fh = director.open('smb://{user}:{pwd}@192.168.1.25/Share/RCAPub.key'.format(user='administrator', pwd='xxx'))