Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #84747 > unrolled thread

write file to a server

Started byluca72 <lucaberto@libero.it>
First post2015-01-28 05:22 -0800
Last post2015-01-28 23:44 -0800
Articles 6 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  write file to a server luca72 <lucaberto@libero.it> - 2015-01-28 05:22 -0800
    Re: write file to a server MRAB <python@mrabarnett.plus.com> - 2015-01-28 13:38 +0000
    Re: write file to a server Chris Angelico <rosuav@gmail.com> - 2015-01-29 01:12 +1100
    Re: write file to a server Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-28 18:05 +0000
    Re: write file to a server Chris Angelico <rosuav@gmail.com> - 2015-01-29 08:38 +1100
    Re: write file to a server luca72 <lucaberto@libero.it> - 2015-01-28 23:44 -0800

#84747 — write file to a server

Fromluca72 <lucaberto@libero.it>
Date2015-01-28 05:22 -0800
Subjectwrite file to a server
Message-ID<6b5943a2-ab9d-4949-bfbe-7671740bb9fb@googlegroups.com>
Hello i'm under windows, i have to write a file from my computer to a local server like taht "\\DOCUMENTALE\my_folder\".
How i have to proceed ?

Thanks 

[toc] | [next] | [standalone]


#84749

FromMRAB <python@mrabarnett.plus.com>
Date2015-01-28 13:38 +0000
Message-ID<mailman.18216.1422452316.18130.python-list@python.org>
In reply to#84747
On 2015-01-28 13:22, luca72 wrote:
> Hello i'm under windows, i have to write a file from my computer to a
> local server like taht "\\DOCUMENTALE\my_folder\".
> How i have to proceed ?
>
That's a path to a folder that just happens to be on another computer on 
your network. Treat it the same way you would for a 'local' folder,
eg "C:\my_folder".

[toc] | [prev] | [next] | [standalone]


#84757

FromChris Angelico <rosuav@gmail.com>
Date2015-01-29 01:12 +1100
Message-ID<mailman.18219.1422454345.18130.python-list@python.org>
In reply to#84747
On Thu, Jan 29, 2015 at 12:38 AM, MRAB <python@mrabarnett.plus.com> wrote:
> On 2015-01-28 13:22, luca72 wrote:
>>
>> Hello i'm under windows, i have to write a file from my computer to a
>> local server like taht "\\DOCUMENTALE\my_folder\".
>> How i have to proceed ?
>>
> That's a path to a folder that just happens to be on another computer on
> your network. Treat it the same way you would for a 'local' folder,
> eg "C:\my_folder".

And if you've done that and it isn't working, one likely cause is that
Windows uses backslashes in path names, but Python string literals
treat backslashes specially. Use a raw string literal:

path = r"\\DOCUMENTALE\my_folder\some_file_name"
with open(path, "wb") as f:
    ... write to file ...

If you have other problems, the best thing to do is to post your code
and the exact output it produces, especially if that's a traceback.
Those are incredibly helpful.

ChrisA

[toc] | [prev] | [next] | [standalone]


#84773

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2015-01-28 18:05 +0000
Message-ID<mailman.18227.1422468354.18130.python-list@python.org>
In reply to#84747
On 28/01/2015 14:12, Chris Angelico wrote:
> On Thu, Jan 29, 2015 at 12:38 AM, MRAB <python@mrabarnett.plus.com> wrote:
>> On 2015-01-28 13:22, luca72 wrote:
>>>
>>> Hello i'm under windows, i have to write a file from my computer to a
>>> local server like taht "\\DOCUMENTALE\my_folder\".
>>> How i have to proceed ?
>>>
>> That's a path to a folder that just happens to be on another computer on
>> your network. Treat it the same way you would for a 'local' folder,
>> eg "C:\my_folder".
>
> And if you've done that and it isn't working, one likely cause is that
> Windows uses backslashes in path names, but Python string literals
> treat backslashes specially. Use a raw string literal:
>
> path = r"\\DOCUMENTALE\my_folder\some_file_name"
> with open(path, "wb") as f:
>      ... write to file ...
>
> If you have other problems, the best thing to do is to post your code
> and the exact output it produces, especially if that's a traceback.
> Those are incredibly helpful.
>
> ChrisA
>

Windows will accept forward slashes in path names.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#84785

FromChris Angelico <rosuav@gmail.com>
Date2015-01-29 08:38 +1100
Message-ID<mailman.18241.1422481132.18130.python-list@python.org>
In reply to#84747
On Thu, Jan 29, 2015 at 5:05 AM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
> Windows will accept forward slashes in path names.

Normally, yes. Does that work for UNC names too?
//server/share/pathname ? In any case, that's an alternative solution
to the same problem.

ChrisA

[toc] | [prev] | [next] | [standalone]


#84803

Fromluca72 <lucaberto@libero.it>
Date2015-01-28 23:44 -0800
Message-ID<1c833144-4113-4efe-9a00-2163781489f0@googlegroups.com>
In reply to#84747
thanks for the reply i have resolve with the r'.........'
i have another question on linux i write cp -Ruv source destination

There is one way to do it in python?
with shutil there is copythree but if the dest dir exist he give back an error.
Can you give me some ideas

Thanks

Luca

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web