Accessing a file in a network drive (python under win32) 
Author Message
 Accessing a file in a network drive (python under win32)

Hi everyone,

I'm porting a program written in Unix to Windows environment.

When I tried to open a file in a network drive (which is from SAMBA server)
using tkFileDialog.askopenfile(), I got the following error message:
IOError: [Errno 2] No such file or directory: '//Evelyn/ms_share/python_win32/jt
ag/t.py'

However ...
(1) It won't complain if I access a file in a local drive (ex) 'C:/config.sys'

(2) I can open the file from IDLE python Shell

Quote:
>>> fd = open('//Evelyn/ms_share/python_win32/jtag/t.py', 'r')

Does anybody have an idea what is going on here?
I'm not export on Windows. But why can't Windows be more like Unix?

Any info would be highly appreciated.

Aki-



Mon, 11 Jul 2005 01:49:38 GMT  
 Accessing a file in a network drive (python under win32)

Quote:

> Hi everyone,

> I'm porting a program written in Unix to Windows environment.

> When I tried to open a file in a network drive (which is from SAMBA server)
> using tkFileDialog.askopenfile(), I got the following error message:
> IOError: [Errno 2] No such file or directory: '//Evelyn/ms_share/python_win32/jt
> ag/t.py'

> However ...
> (1) It won't complain if I access a file in a local drive (ex) 'C:/config.sys'

> (2) I can open the file from IDLE Python Shell
> >>> fd = open('//Evelyn/ms_share/python_win32/jtag/t.py', 'r')

> Does anybody have an idea what is going on here?
> I'm not export on Windows. But why can't Windows be more like Unix?

> Any info would be highly appreciated.

> Aki-

Try using windows delimiters:
fd = open(r"\\Evelyn\ms_share\python_win32\jtag\t.py")

Notice I used a re string so that I didn't need to escape each backslash:
open("\\\\Evelyn\\ms_share\\python_win32\\jtag\\t.py")



Mon, 11 Jul 2005 07:30:28 GMT  
 Accessing a file in a network drive (python under win32)
Hi !

I have the same problem. I had try  /  and  \    it's equal.
I have found than there are no problem, if there are no space into the
pathname...
I have too the problem with os.chdir  but  i have no problem if i
"decompose" :

                    os.chdir('E:\Program Files\toto\tutu')        problem

                    os.chdir("E:\\")
no problem
                    os.chdir("\\Program Files")
                    os.chdir('toto')
                    os.chdir('tutu')

Sorry, i no found solution, but only infos  (and re-sorry for my bad
english).



Mon, 11 Jul 2005 08:10:04 GMT  
 Accessing a file in a network drive (python under win32)

Quote:
> '//Evelyn/ms_share/python_win32/jt ag/t.py'

Assign it as a string to a variable and use the variable.

That is how I did it recently and I did not get any errors with it.  I
was using v2.1 if that makes any difference.

-----
Doug



Mon, 11 Jul 2005 08:18:57 GMT  
 Accessing a file in a network drive (python under win32)
Quote:

> Hi everyone,

> I'm porting a program written in Unix to Windows environment.

> When I tried to open a file in a network drive (which is from SAMBA server)
> using tkFileDialog.askopenfile(), I got the following error message:
> IOError: [Errno 2] No such file or directory: '//Evelyn/ms_share/python_win32/jt
> ag/t.py'

It depends on your current workdevice
'//Evelyn/ms_share/python_win32/jtag/t.py'
is looking for the above directory on your current device

Quote:
> However ...
> (1) It won't complain if I access a file in a local drive (ex) 'C:/config.sys'

Here you're searching config.sys explicitly on device C:
e.g saying os.chdir('d:')
will show
Quote:
>>> os.getcwd()

'D:\\'
But now
Quote:
>>> os.chdir('\\windows')

will fail
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
OSError: [Errno 2] No such file or directory: '\\windows'
because windows is on C:
So
Quote:
>>> os.chdir('c:\\windows')
helps and shows
>>> os.getcwd()

'c:\\windows'

Quote:
> (2) I can open the file from IDLE Python Shell
> >>> fd = open('//Evelyn/ms_share/python_win32/jtag/t.py', 'r')

> Does anybody have an idea what is going on here?
> I'm not export on Windows. But why can't Windows be more like Unix?

I think before your open( ... ) command you changed your device.

Quote:

> Any info would be highly appreciated.

> Aki-

BTW
In Python
  open( 'C:\\windows\\system32') is equivalent to
  open(r'C:\windows\system32') is equivalent to
  open( 'C:/windows/system32')
The '\' is an escape-character to indicate
special characters as Tab: '\t', newline: '\n' etc. or
!!!!! Backslash: '\\' !!!!!
To avoid '\\' you can use so-called raw-strings which
start with an r' ... ' and you can write
Backslash: r'\'

Hope, I could help you
Peter



Tue, 12 Jul 2005 07:39:49 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Copy file from network drive to local drive?

2. Python on shared network drive?

3. Copy file from network drive?

4. Opening files on a network drive.

5. PHP files don't work in Windows network drive

6. Win32: python-network-installation?

7. are MS Access File Drives available ???

8. Accessing mdb(access 2000) files on linux using python

9. Q: Network access & Python

10. Concurrent file access over network

11. win32 - create/access file properties on NTFS

12. Exclusive file access or serial access to external file

 

 
Powered by phpBB® Forum Software