Re: How to open a remote file using python.

2009-02-22 Thread odeits
On Feb 22, 9:02 pm, venutaurus...@gmail.com
venutaurus...@gmail.com wrote:
 On Feb 23, 9:25 am, MRAB goo...@mrabarnett.plus.com wrote:



  venutaurus...@gmail.com wrote:
   Hello all,
              I am writing an application where I need to open a shared
   file on a remote machine using python script. I tried using the
   following function:

   f = urllib.open(\\remote_machine\\folder1\\file1.doc)

            I also tried using

   class urllib.FancyURLopener(...)

            but didn't work. Can some one help me in this regard.

  What do you mean by remote machine? Do you mean you want to open a
  file that's in a shared folder on a machine that's on the same local
  network?

  If it's meant to be a Windows filepath then it should be:

       f = open(r\\remote_machine\folder1\file1.doc)

  (If the file is a Microsoft Word document file, then you won't probably
  be able to make much sense of its contents using open().)

 Thanks to all for your brisk replies:

         Yes, my aim is to open a file from another machine in the same
 LAN. It also worked using

 f = urllib.urlopen(\\\remote_machine\\folder\\file.doc)

         But now I also have to copy the same file to the local machine
 in Python. Do I need to follow any protocols for this?

 Thank you,
 Venu.

the copy in shutil will work just fine.
import shutil
shutil.copy(remotepath,localpath)
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to open a remote file using python.

2009-02-22 Thread Chris Rebert
On Sun, Feb 22, 2009 at 9:02 PM, venutaurus...@gmail.com
venutaurus...@gmail.com wrote:
 On Feb 23, 9:25 am, MRAB goo...@mrabarnett.plus.com wrote:
 venutaurus...@gmail.com wrote:
  Hello all,
 I am writing an application where I need to open a shared
  file on a remote machine using python script. I tried using the
  following function:

  f = urllib.open(\\remote_machine\\folder1\\file1.doc)

   I also tried using

  class urllib.FancyURLopener(...)

   but didn't work. Can some one help me in this regard.

 What do you mean by remote machine? Do you mean you want to open a
 file that's in a shared folder on a machine that's on the same local
 network?

 If it's meant to be a Windows filepath then it should be:

  f = open(r\\remote_machine\folder1\file1.doc)

 (If the file is a Microsoft Word document file, then you won't probably
 be able to make much sense of its contents using open().)

 Thanks to all for your brisk replies:

Yes, my aim is to open a file from another machine in the same
 LAN. It also worked using

f = urllib.urlopen(\\\remote_machine\\folder\\file.doc)

But now I also have to copy the same file to the local machine
 in Python. Do I need to follow any protocols for this?

You may find urllib.urlretrieve() useful for accomplishing that.

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list


How to open a remote file using python.

2009-02-22 Thread venutaurus...@gmail.com
Hello all,
   I am writing an application where I need to open a shared
file on a remote machine using python script. I tried using the
following function:

f = urllib.open(\\remote_machine\\folder1\\file1.doc)

 I also tried using

class urllib.FancyURLopener(...)

 but didn't work. Can some one help me in this regard.

Thank you in advance,
Venu
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to open a remote file using python.

2009-02-22 Thread Chris Rebert
On Sun, Feb 22, 2009 at 8:13 PM, venutaurus...@gmail.com
venutaurus...@gmail.com wrote:
 Hello all,
   I am writing an application where I need to open a shared
 file on a remote machine using python script. I tried using the
 following function:

 f = urllib.open(\\remote_machine\\folder1\\file1.doc)

 I also tried using

 class urllib.FancyURLopener(...)

 but didn't work. Can some one help me in this regard.

That function and class are be for retrieving materials over the web
(typically HTTP/FTP); however, your path suggests you're trying to
access a file over a local Windows network, so those aren't
appropriate. The regular open() function would have a better chance of
working for this. Have you tried it?

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to open a remote file using python.

2009-02-22 Thread MRAB

venutaurus...@gmail.com wrote:

Hello all,
   I am writing an application where I need to open a shared
file on a remote machine using python script. I tried using the
following function:

f = urllib.open(\\remote_machine\\folder1\\file1.doc)

 I also tried using

class urllib.FancyURLopener(...)

 but didn't work. Can some one help me in this regard.


What do you mean by remote machine? Do you mean you want to open a
file that's in a shared folder on a machine that's on the same local
network?

If it's meant to be a Windows filepath then it should be:

f = open(r\\remote_machine\folder1\file1.doc)

(If the file is a Microsoft Word document file, then you won't probably
be able to make much sense of its contents using open().)
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to open a remote file using python.

2009-02-22 Thread venutaurus...@gmail.com
On Feb 23, 9:25 am, MRAB goo...@mrabarnett.plus.com wrote:
 venutaurus...@gmail.com wrote:
  Hello all,
             I am writing an application where I need to open a shared
  file on a remote machine using python script. I tried using the
  following function:

  f = urllib.open(\\remote_machine\\folder1\\file1.doc)

           I also tried using

  class urllib.FancyURLopener(...)

           but didn't work. Can some one help me in this regard.

 What do you mean by remote machine? Do you mean you want to open a
 file that's in a shared folder on a machine that's on the same local
 network?

 If it's meant to be a Windows filepath then it should be:

      f = open(r\\remote_machine\folder1\file1.doc)

 (If the file is a Microsoft Word document file, then you won't probably
 be able to make much sense of its contents using open().)

Thanks to all for your brisk replies:

Yes, my aim is to open a file from another machine in the same
LAN. It also worked using

f = urllib.urlopen(\\\remote_machine\\folder\\file.doc)

But now I also have to copy the same file to the local machine
in Python. Do I need to follow any protocols for this?

Thank you,
Venu.











--
http://mail.python.org/mailman/listinfo/python-list