Problems opening a file in a shared dir

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • luke14free
    New Member
    • Apr 2007
    • 79

    Problems opening a file in a shared dir

    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\\Sha redDocs\\Musica \\Musica campione\\a.wma
    I tried to use os.system and open:
    Code:
    open("\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma","r").read()
    Traceback (most recent call last):
      File "<pyshell#3>", line 1, in <module>
        open("\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma","r").read()
    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
  • rogerlew
    New Member
    • Jun 2007
    • 15

    #2
    It will work if you "map" the network share.

    Comment

    • STM
      New Member
      • Dec 2007
      • 4

      #3
      Originally posted by 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\\Sha redDocs\\Musica \\Musica campione\\a.wma
      I tried to use os.system and open:
      Code:
      open("\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma","r").read()
      Traceback (most recent call last):
        File "<pyshell#3>", line 1, in <module>
          open("\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma","r").read()
      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:
      Code:
      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

      Comment

      • ilikepython
        Recognized Expert Contributor
        • Feb 2007
        • 844

        #4
        Originally posted by 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\\Sha redDocs\\Musica \\Musica campione\\a.wma
        I tried to use os.system and open:
        Code:
        open("\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma","r").read()
        Traceback (most recent call last):
          File "<pyshell#3>", line 1, in <module>
            open("\\NOTEBOOK\\SharedDocs\\Musica\\Musica campione\\a.wma","r").read()
        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:
        [code=python]
        open/os.system('"\\N OTEBOOK\\...... \\a.wma"')
        [/code]

        Comment

        • ghostdog74
          Recognized Expert Contributor
          • Apr 2006
          • 511

          #5
          demo
          Code:
          >>> import os
          >>> os.path.join("c:\\","test","file with space.txt")
          'c:\\test\\file with space.txt'
          >>> os.path.exists (os.path.join("c:\\","test","file with space.txt")) 
          True
          >>> f=open(os.path.join("c:\\","test","file with space.txt"))
          >>> f.read()
          'qweqwd'
          >>> f.close()
          ensure that you have a valid drive letter assigned to your mapped drive.

          Comment

          • luke14free
            New Member
            • Apr 2007
            • 79

            #6
            Problem solved using os.system and win32api.execut e. I wasn't able to map drives because the program works on more than 30pcs...it was kinda impossible...
            Thanks for help,
            Luce

            Comment

            Working...