471,321 Members | 1,747 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,321 software developers and data experts.

Problems opening a file in a shared dir

luke14free
Hello,
I'm using Windows XP and Windows Server 2003 for a work.
I need to copy a file from shared dir to my pc. This is my file location.
\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma
I tried to use os.system and open:
Expand|Select|Wrap|Line Numbers
  1. open("\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma","r").read()
  2. Traceback (most recent call last):
  3.   File "<pyshell#3>", line 1, in <module>
  4.     open("\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma","r").read()
  5. IOError: [Errno 2] No such file or directory: '\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma'
And system returns nothing...But nothing happens too. (in fact cmd tells me that the folder path is unknown). I've got all the right privileges, because using explorer I can get my file.
Thank you,
Luca
Dec 18 '07 #1
5 1381
It will work if you "map" the network share.
http://www.microsoft.com/windowsxp/u.../mapdrive.mspx
Dec 19 '07 #2
STM
4
Hello,
I'm using Windows XP and Windows Server 2003 for a work.
I need to copy a file from shared dir to my pc. This is my file location.
\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma
I tried to use os.system and open:
Expand|Select|Wrap|Line Numbers
  1. open("\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma","r").read()
  2. Traceback (most recent call last):
  3.   File "<pyshell#3>", line 1, in <module>
  4.     open("\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma","r").read()
  5. IOError: [Errno 2] No such file or directory: '\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma'
And system returns nothing...But nothing happens too. (in fact cmd tells me that the folder path is unknown). I've got all the right privileges, because using explorer I can get my file.
Thank you,
it s just a guess, but try writing the open call like this:
Expand|Select|Wrap|Line Numbers
  1. open(r'\NOTEBOOK\SharedDocs\Musica\Musica campione\a.wma','r').read()
the way you wrote it may have problems with escape sequences
let me know if that was the problem
Dec 22 '07 #3
ilikepython
844 Expert 512MB
Hello,
I'm using Windows XP and Windows Server 2003 for a work.
I need to copy a file from shared dir to my pc. This is my file location.
\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma
I tried to use os.system and open:
Expand|Select|Wrap|Line Numbers
  1. open("\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma","r").read()
  2. Traceback (most recent call last):
  3.   File "<pyshell#3>", line 1, in <module>
  4.     open("\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma","r").read()
  5. IOError: [Errno 2] No such file or directory: '\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma'
And system returns nothing...But nothing happens too. (in fact cmd tells me that the folder path is unknown). I've got all the right privileges, because using explorer I can get my file.
Thank you,
Luca
I'm not sure but the problem might be because of the space in the path. Try calling it like this:
Expand|Select|Wrap|Line Numbers
  1. open/os.system('"\\NOTEBOOK\\......\\a.wma"')
  2.  
Dec 23 '07 #4
ghostdog74
511 Expert 256MB
demo
Expand|Select|Wrap|Line Numbers
  1. >>> import os
  2. >>> os.path.join("c:\\","test","file with space.txt")
  3. 'c:\\test\\file with space.txt'
  4. >>> os.path.exists (os.path.join("c:\\","test","file with space.txt")) 
  5. True
  6. >>> f=open(os.path.join("c:\\","test","file with space.txt"))
  7. >>> f.read()
  8. 'qweqwd'
  9. >>> f.close()
  10.  
ensure that you have a valid drive letter assigned to your mapped drive.
Dec 23 '07 #5
Problem solved using os.system and win32api.execute. I wasn't able to map drives because the program works on more than 30pcs...it was kinda impossible...
Thanks for help,
Luce
Jan 10 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by me | last post: by
1 post views Thread by electrixnow | last post: by
2 posts views Thread by Mike | last post: by
5 posts views Thread by Simon | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.