Problem while copying a file from a remote filer

Discussion in 'Python' started by venutaurus539, Mar 16, 2009.

  1. Hi all,
    I have to write an application which does a move and copy of a
    file from a remote machine to the local machine. I tried something

    file = ur"\\\\venuwin2008\\C\\4Folders\\Folder02\\Folder002\
    dest = "C:\\test"

    But it is throwing an error:

    Traceback (most recent call last):
    File "E:\venu\Testing Team\", line 22, in <module>
    File "C:\Python26\lib\", line 88, in copy
    copyfile(src, dst)
    File "C:\Python26\lib\", line 52, in copyfile
    fsrc = open(src, 'rb')
    IOError: [Errno 22] invalid mode ('rb') or filename: u'\\\\\\\

    Can some one please help me in this regard.

    Thank you
    Venu madhav
    venutaurus539, Mar 16, 2009
    1. Advertisements

  2. venutaurus539

    Chris Rebert Guest

    The 'r' prefix on the string makes it a raw string, meaning you don't
    have do double-up the backslashes, but you did so anyway, so your path
    has many extra backslashes, making it invalid. Dropping the 'r' prefix
    should fix the problem.

    Chris Rebert, Mar 16, 2009
    1. Advertisements

  3. venutaurus539

    Jorgen Grahn Guest

    Also, the file isn't really remote if you can use the normal local
    file system calls to read it.

    Jorgen Grahn, Mar 17, 2009
  4. venutaurus539

    Tim Golden Guest

    That's a slightly strange position to take.
    When *is* it remote, then?

    Tim Golden, Mar 17, 2009
  5. venutaurus539

    Aahz Guest

    Alternatively, and I think better practice, undouble the backslashes
    instead of removing the 'r' prefix.
    Aahz () <*>

    "At Resolver we've found it useful to short-circuit any doubt and just
    refer to comments in code as 'lies'. :)"
    --Michael Foord paraphrases Christian Muirhead on python-dev, 2009-3-22
    Aahz, Mar 25, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.