2017-07-19 7 views
0

Utilisation de cette bibliothèque: https://pypi.python.org/pypi/PySmbClient J'essaie d'accéder à un fichier de mon ordinateur Ubuntu via un partage smb à partir d'une machine Windows.Python ne peut pas accéder au fichier à l'aide du client smb

La part est en cours d'exécution bien et je peux voir les fichiers mais, lorsque je tente d'accéder aux fichiers à partir d'un script Phyton, je continue à obtenir cette erreur:

<SambaClient('topit/topit'@'//oberon/depot')> 
Traceback (most recent call last): 
    File "runTest.py", line 56, in <module> 
    f = smb.open('estimate.sql') 
    File "/home/matejb/Development/dcm-test/smbclient.py", line 408, in open 
    f = _SambaFile(self, path, mode) 
    File "/home/matejb/Development/dcm-test/smbclient.py", line 448, in __init__ 
    connection.download(remote_name, self._tmp_name) 
    File "/home/matejb/Development/dcm-test/smbclient.py", line 393, in download 
    result = self._runcmd('get', remote_path, local_path) 
    File "/home/matejb/Development/dcm-test/smbclient.py", line 184, in _runcmd 
    return self._raw_runcmd(fullcmd) 
    File "/home/matejb/Development/dcm-test/smbclient.py", line 168, in _raw_runcmd 
    stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 
    File "/usr/lib/python2.7/subprocess.py", line 711, in __init__ 
    errread, errwrite) 
    File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child 
    raise child_exception 
OSError: [Errno 2] No such file or directory 

Mon code:

import smbclient 

smb = smbclient.SambaClient(server="oberon", share="depot", 
           username='topit', password='topit', domain='topit') 
print smb 

f = smb.open('estimate.sql') 
data = f.read() 

print data 

Répondre

0

Essayez

sudo apt-get update && sudo apt-get install -y --no-install-recommends smbclient 

Parce qu'il fonctionne en exécutant le "smbclient" sous-processus