Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26621 > unrolled thread
| Started by | "S.B" <hyperboogie@gmail.com> |
|---|---|
| First post | 2012-08-06 06:32 -0700 |
| Last post | 2012-08-08 16:07 +0100 |
| Articles | 9 — 5 participants |
Back to article view | Back to comp.lang.python
Pickle file and send via socket "S.B" <hyperboogie@gmail.com> - 2012-08-06 06:32 -0700
Re: Pickle file and send via socket Nobody <nobody@nowhere.com> - 2012-08-06 17:11 +0100
Re: Pickle file and send via socket Christian Heimes <lists@cheimes.de> - 2012-08-06 18:45 +0200
Re: Pickle file and send via socket Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-06 15:26 -0400
Re: Pickle file and send via socket "S.B" <hyperboogie@gmail.com> - 2012-08-07 04:21 -0700
Re: Pickle file and send via socket lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-07 14:07 +0100
Re: Pickle file and send via socket lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-08 13:48 +0100
Re: Pickle file and send via socket "S.B" <hyperboogie@gmail.com> - 2012-08-08 06:50 -0700
Re: Pickle file and send via socket lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-08 16:07 +0100
| From | "S.B" <hyperboogie@gmail.com> |
|---|---|
| Date | 2012-08-06 06:32 -0700 |
| Subject | Pickle file and send via socket |
| Message-ID | <f3b73b0e-1520-4768-a1d2-bb754357dfc7@googlegroups.com> |
Hello friends Does anyone know if it's possible to pickle and un-pickle a file across a network socket. i.e: First host pickles a file object and writes the pickled file object to a client socket. Second host reads the pickled file object from the server socket and un-pickles it. Can anyone provide a simple code example of the client and server sides? Thanks
[toc] | [next] | [standalone]
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Date | 2012-08-06 17:11 +0100 |
| Message-ID | <pan.2012.08.06.16.11.55.540000@nowhere.com> |
| In reply to | #26621 |
On Mon, 06 Aug 2012 06:32:13 -0700, S.B wrote: > Does anyone know if it's possible to pickle and un-pickle a file across > a network socket. i.e: First host pickles a file object and writes the > pickled file object to a client socket. Second host reads the pickled > file object from the server socket and un-pickles it. Yes, provided that the socket is a stream socket (e.g. TCP, Unix), not a datagram socket (e.g. UDP). > Can anyone provide a simple code example of the client and server sides? Pickling via a socket is no different to pickling via a file. For a socket, the .makefile() method will return a suitable file object.
[toc] | [prev] | [next] | [standalone]
| From | Christian Heimes <lists@cheimes.de> |
|---|---|
| Date | 2012-08-06 18:45 +0200 |
| Message-ID | <mailman.3018.1344271574.4697.python-list@python.org> |
| In reply to | #26621 |
Am 06.08.2012 15:32, schrieb S.B: > Does anyone know if it's possible to pickle and un-pickle a file across a network socket. i.e: > First host pickles a file object and writes the pickled file object to a client socket. > Second host reads the pickled file object from the server socket and un-pickles it. Have you read the warning in the first paragraph of the pickle docs? Pickles are a major security risk unless both hosts are trustworthy and are either inside a protected network or are connected over a secure line. http://docs.python.org/library/pickle.html#module-pickle Warning The pickle module is not intended to be secure against erroneous or maliciously constructed data. Never unpickle data received from an untrusted or unauthenticated source. Christian Heimes
[toc] | [prev] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2012-08-06 15:26 -0400 |
| Message-ID | <mailman.3024.1344281415.4697.python-list@python.org> |
| In reply to | #26621 |
On Mon, 6 Aug 2012 19:17:47 +0530, Ramchandra Apte
<maniandram01@gmail.com> declaimed the following in
gmane.comp.python.general:
> This is *absolutely* possible.
> Did you know that IDLE uses this very method when run in sub-process mode!
>
It must be emphasized that this is likely to only work on the local
machine... Passing a pickled file-object across the net to different
machine will likely fail.
It also will be impacted by the normal pickle restrictions (that a
different version of Python may not be able to unpickle the data).
I don't know enough to know if M$ Windows operates in the same
manner with regards to file objects.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [next] | [standalone]
| From | "S.B" <hyperboogie@gmail.com> |
|---|---|
| Date | 2012-08-07 04:21 -0700 |
| Message-ID | <02cdd15c-2517-48fc-96e5-24a094b0b850@googlegroups.com> |
| In reply to | #26621 |
On Monday, August 6, 2012 4:32:13 PM UTC+3, S.B wrote: > Hello friends > > > > Does anyone know if it's possible to pickle and un-pickle a file across a network socket. i.e: > > First host pickles a file object and writes the pickled file object to a client socket. > > Second host reads the pickled file object from the server socket and un-pickles it. > > > > Can anyone provide a simple code example of the client and server sides? > > > > Thanks Lot's of conflicting answers :-( Can anyone provide a simple code example?
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <lipskathekat@yahoo.co.uk> |
|---|---|
| Date | 2012-08-07 14:07 +0100 |
| Message-ID | <SMWdnbQRtbdij7zNnZ2dnUVZ8lCdnZ2d@bt.com> |
| In reply to | #26700 |
On 07/08/12 12:21, S.B wrote: >> >> >> >> Can anyone provide a simple code example of the client and server sides? Working on it lipska -- Lipska the Kat: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <lipskathekat@yahoo.co.uk> |
|---|---|
| Date | 2012-08-08 13:48 +0100 |
| Message-ID | <WtqdncCw6amw_b_NnZ2dnUVZ7tGdnZ2d@bt.com> |
| In reply to | #26621 |
On 06/08/12 14:32, S.B wrote: > Hello friends > > Does anyone know if it's possible to pickle and un-pickle a file across a network socket. i.e: > First host pickles a file object and writes the pickled file object to a client socket. > Second host reads the pickled file object from the server socket and un-pickles it. > > Can anyone provide a simple code example of the client and server sides? > > Thanks > Hi Firstly I am a raw beginner at Python and I don't publish this code as a good example of anything. It works for me on Ubuntu Linux 12.04 and Python3.2 As usual I welcome constructive comments but I will be working on this more to help me understand exactly what is going on http://pastebin.com/iFzK7fuk SpaceTravellers.py http://pastebin.com/TdqPwMGi NetworkPickler.py http://pastebin.com/DF5DtYRZ NetworkUnpickler.py lipska -- Lipska the Kat: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun
[toc] | [prev] | [next] | [standalone]
| From | "S.B" <hyperboogie@gmail.com> |
|---|---|
| Date | 2012-08-08 06:50 -0700 |
| Message-ID | <674b1cd4-5f7d-47ce-924d-76f5306746bc@googlegroups.com> |
| In reply to | #26756 |
On Wednesday, August 8, 2012 3:48:43 PM UTC+3, lipska the kat wrote: > On 06/08/12 14:32, S.B wrote: > > > Hello friends > > > > > > Does anyone know if it's possible to pickle and un-pickle a file across a network socket. i.e: > > > First host pickles a file object and writes the pickled file object to a client socket. > > > Second host reads the pickled file object from the server socket and un-pickles it. > > > > > > Can anyone provide a simple code example of the client and server sides? > > > > > > Thanks > > > > > > > Hi > > > > Firstly I am a raw beginner at Python and I don't publish this code > > as a good example of anything. It works for me on Ubuntu Linux 12.04 and > > Python3.2 > > > > As usual I welcome constructive comments but I will be working on this > > more to help me understand exactly what is going on > > > > http://pastebin.com/iFzK7fuk SpaceTravellers.py > > http://pastebin.com/TdqPwMGi NetworkPickler.py > > http://pastebin.com/DF5DtYRZ NetworkUnpickler.py > > > > lipska > > > > -- > > Lipska the Kat: Troll hunter, sandbox destroyer > > and farscape dreamer of Aeryn Sun Thank you so much ! The examples are very helpful. What happens if I have a regular text file I want to send via the network. Do I need to read the file and then dump it into the "stargate" file object?
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <lipskathekat@yahoo.co.uk> |
|---|---|
| Date | 2012-08-08 16:07 +0100 |
| Message-ID | <37mdnchk-JMqHb_NnZ2dnUVZ7tidnZ2d@bt.com> |
| In reply to | #26758 |
On 08/08/12 14:50, S.B wrote: > On Wednesday, August 8, 2012 3:48:43 PM UTC+3, lipska the kat wrote: >> On 06/08/12 14:32, S.B wrote: >> [snip] > Thank you so much ! > The examples are very helpful. > What happens if I have a regular text file I want to send via the network. > Do I need to read the file and then dump it into the "stargate" file object? Well according to the documentation at http://docs.python.org/py3k/tutorial/inputoutput.html#reading-and-writing-files it should be straightforward to read and write pickled files Not sure why you want to pickle a text file over the network when you could just stream it between ports ! however ... I'm currently getting a Unicode decode error on the first byte in the stream when it gets to the other end, no idea why so I guess I have to continue searching, read the documentation above and see if you can figure it out, that's what I'm doing. lipska -- Lipska the Kat: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web