[Tutor] Tutor Digest, Vol 88, Issue 83

arun kumar arunkumar413 at gmail.com
Tue Jun 21 09:56:54 CEST 2011


On Tue, Jun 21, 2011 at 12:46 PM, <tutor-request at python.org> wrote:

> Send Tutor mailing list submissions to
>        tutor at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
>        tutor-request at python.org
>
> You can reach the person managing the list at
>        tutor-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
>
>
> Today's Topics:
>
>   1. Re: html files to pdf document (Timo)
>   2. Re: html files to pdf document (Michiel Overtoom)
>   3. Re: html files to pdf document (Walter Prins)
>   4. Re: html files to pdf document (Michiel Overtoom)
>   5. Socket Programming issue (aditya)
>   6. Re: Socket Programming issue (Alan Gauld)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 20 Jun 2011 18:58:56 +0200
> From: Timo <timomlists at gmail.com>
> To: tutor at python.org
> Subject: Re: [Tutor] html files to pdf document
> Message-ID: <4DFF7C50.3000405 at gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 20-06-11 17:34, arun kumar wrote:
> > HI,  i have a some 100 plus html individual files.I want to convert
> > them to a single pdf document programatically. How to convert them in
> >  python. Are there any functions,modules or libraries for python to
> > achieve this.
> Just a question, but did you use Google before asking here? Because the
> first hit when searching for "python html to pdf" looks like it should
> do what you want.
>

Cheers,
> Timo
>
> >
> > --
> > Thank you
> >
> > Arun Kumar
> > http://clicknscroll.blogspot.com
> >
> >
> >
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > To unsubscribe or change subscription options:
> > http://mail.python.org/mailman/listinfo/tutor
>
>
> yes i did a Google search but  did find anything useful. The xhtml2pdf is
> buggy in i'm unable to install it. Also mailed the community of  xhtml2pdf
> but didn't receive any reply from  them.
>

   Thanks
   Arun Kumar

> ------------------------------
>
> Message: 2
> Date: Mon, 20 Jun 2011 19:11:13 +0200
> From: Michiel Overtoom <motoom at xs4all.nl>
> To: tutor at python.org
> Subject: Re: [Tutor] html files to pdf document
> Message-ID: <00E86B69-6D07-46ED-B4CA-4F740509BB0B at xs4all.nl>
> Content-Type: text/plain; charset=us-ascii
>
>
> On Jun 20, 2011, at 18:58, Timo wrote:
>
> > On 20-06-11 17:34, arun kumar wrote:
> >> HI,  i have a some 100 plus html individual files.I want to convert them
> to a single pdf document programatically. How to convert them in  python.
> Are there any functions,modules or libraries for python to achieve this.
>
> > Just a question, but did you use Google before asking here? Because the
> first hit when searching for "python html to pdf" looks like it should do
> what you want.
>
> Maybe for you, but not for the OP. Google will give different search
> results depending on your location, nationality, IP address and previous
> searches from that address.
>
> Please post the URL of the first hit you got?
>
> Greetings,
>
> --
> "Freedom: To ask nothing. To expect nothing. To depend on nothing." - Ayn
> Rand
>
>
>
> ------------------------------
>
> Message: 3
> Date: Mon, 20 Jun 2011 23:19:52 +0100
> From: Walter Prins <wprins at gmail.com>
> To: tutor at python.org
> Subject: Re: [Tutor] html files to pdf document
> Message-ID: <BANLkTikJoY34-Z2Uja1HBa4rYx3sq6i=XQ at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hello,
>
> On 20 June 2011 18:11, Michiel Overtoom <motoom at xs4all.nl> wrote:
>
> >
> > On Jun 20, 2011, at 18:58, Timo wrote:
> >
> > > On 20-06-11 17:34, arun kumar wrote:
> > >> HI,  i have a some 100 plus html individual files.I want to convert
> them
> > to a single pdf document programatically. How to convert them in  python.
> > Are there any functions,modules or libraries for python to achieve this.
> >
> > > Just a question, but did you use Google before asking here? Because the
> > first hit when searching for "python html to pdf" looks like it should do
> > what you want.
> >
> > Maybe for you, but not for the OP. Google will give different search
> > results depending on your location, nationality, IP address and previous
> > searches from that address.
> >
>
> At the risk of belaboring the point, I think what Timo was gentlying trying
> to point out to the OP was that Google would've likely yielded many
> relevant
> results, including in all likelihood the top hit, notwithstanding Google's
> tailoring based on location and other factors.  (You're not seriously
> trying
> to suggest that Google would've yielded *no* useful results, or that the
> top
> link wouldn't have been at all relevant to his question, are you?)
>
> For reference, for me the top hit is http://www.xhtml2pdf.com/ which does
> indeed look like it might do the job (and is a pure python solution.)
>
> Another possibly quite relevant link is this one (about 20 lines of code):
>
> http://www.linux.com/learn/docs/ldp/284676-converting-html-to-pdf-using-python-and-qt
>
> Cheers
>
> Walter
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20110620/3aa076cd/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 4
> Date: Tue, 21 Jun 2011 00:29:27 +0200
> From: Michiel Overtoom <motoom at xs4all.nl>
> To: tutor at python.org
> Subject: Re: [Tutor] html files to pdf document
> Message-ID: <994B3638-CD1E-449D-86AE-29A2AF0418A2 at xs4all.nl>
> Content-Type: text/plain; charset=us-ascii
>
>
> On Jun 21, 2011, at 00:19, Walter Prins wrote:
>
> > For reference, for me the top hit is http://www.xhtml2pdf.com/ which
> does indeed look like it might do the job (and is a pure python solution.)
>
> I get five SERP pages with tons of Stackoverflow hits, but not one for
> www.xhtml2pdf.com!  I think this is what is known as an Internet Search
> Bubble.
>
>
> > Another possibly quite relevant link is this one (about 20 lines of
> code):
> http://www.linux.com/learn/docs/ldp/284676-converting-html-to-pdf-using-python-and-qt
>
> Thank you for posting the links.
>
> Greetings,
>
> --
> "If you don't know, the thing to do is not to get scared, but to learn." -
> Ayn Rand
>
> Hi Micheal,
>
Thanks for the suggestion but  my  desktop environment  is not qt. Its
gnome. And i'm looking for some pure python way. www.xhtml2pdf is buggy and
i had problems installing that library

Thanks

Arun Kumar

>
>
>
> ------------------------------
>
> Message: 5
> Date: Tue, 21 Jun 2011 11:11:51 +0530
> From: aditya <nauty.me04 at gmail.com>
> To: tutor at python.org
> Subject: [Tutor] Socket Programming issue
> Message-ID: <BANLkTikS+gzm=89tHCZpbWKSd+wUfeC7mA at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> This is a small client-server program in which i am using a Vbscript
> program
> to check for connectivity of 2 machines and write the output to a text file
> whether it connectes or not ,
>
>
> for example the contents of the file *output.txt* are
>
> 192.168.1.2 is connected
> 192.168.1.10 is not connected
>
>
> Now i am trying to send the contents of this file from a client through a
> socket to a server which is running on my main server .This is basically
> created to automate the checking of connectivity of the machines. The issue
> is that although the Vbscript writes the output to the file correctly but
> when the client sends the contents of the file to the server via socket ,
> it
> sometimes prints all the lines of the file on the server and sometimes it
> doesnt , i dont know whether the issue is with the client or the server ,
> Please Help..
>
>
> CLIENT.PY
>
> import socket
> import os
> import sys
> os.system("C:\Python26\ping.vbs")
> host = "localhost"
> port= 23333
> size = 1024
>
> s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.connect((host,port))
>
>
>
>
> f=open('output.txt','r')
> while 1:
> data = f.readline()
> if data: s.send(data)
>  else: break
>
>
>
> f.close()
>
> s.close()
>
>
>
> SERVER.PY
>
>
> import socket
>
> host = ""
> port = 23333
> size = 1024
> backlog=5
> s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>
> s.bind((host,port))
> s.listen(backlog)
>
> while 1:
> client, addr =s.accept()
> data=client.recv(size)
> if data:
> print data
>
> else:
> print  "client exit"
>
> s.close()
>
>
>
>
>
>
>
>
>
> --
> Regards
> Aditya
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20110621/b2cd975c/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 6
> Date: Tue, 21 Jun 2011 08:15:55 +0100
> From: "Alan Gauld" <alan.gauld at btinternet.com>
> To: tutor at python.org
> Subject: Re: [Tutor] Socket Programming issue
> Message-ID: <itpgfd$3eo$1 at dough.gmane.org>
> Content-Type: text/plain; format=flowed; charset="iso-8859-1";
>        reply-type=original
>
>
> "aditya" <nauty.me04 at gmail.com> wrote
>
> > is that although the Vbscript writes the output to the file
> > correctly but
> > when the client sends the contents of the file to the server via
> > socket , it
> > sometimes prints all the lines of the file on the server and
> > sometimes it
> > doesnt , i dont know whether the issue is with the client or the
> > server ,
>
> Use the return values from functions.
>
> > CLIENT.PY
> >
> > import socket
> > import os
> > import sys
> > os.system("C:\Python26\ping.vbs")
> > host = "localhost"
> > port= 23333
> > size = 1024
> >
> > s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> > s.connect((host,port))
> >
> > f=open('output.txt','r')
> > while 1:
> > data = f.readline()
>
> You could print the data here to check that you got something
> meaningful from the file....
>
> > if data: s.send(data)
>
> The socket documentation specifically says:
> ---------------------------------
> socket.send(string[, flags])
>  Send data to the socket. The socket must be connected to a remote
> socket. The optional flags argument has the same meaning as for recv()
> above. Returns the number of bytes sent. Applications are responsible
> for checking that all data has been sent; if only some of the data was
> transmitted, the application needs to attempt delivery of the
> remaining data.
>
> ------------------------------------------
> Notice that it tells you how many bytes have been sent, and it
> is your responsibility to check and retry if necessary.
> I see no check nor any attempt to retry....
>
> That should tell you if the data is leaving the client at least.
>
>
> > SERVER.PY
> > import socket
> >
> > host = ""
> > port = 23333
> > size = 1024
> > backlog=5
> > s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> >
> > s.bind((host,port))
> > s.listen(backlog)
> >
> > while 1:
> > client, addr =s.accept()
> > data=client.recv(size)
> > if data:
> > print data
> > else:
> > print  "client exit"
>
> This implies you should always get something printed, do you?
> When you say it sometimes prints the lines and sometimes
> not, does it print the exit message instead?
>
> > s.close()
>
> I'm not clear where this line sits since the mail has lost
> its indentation. Is it inside the else or at the while level?
>
> Just some things to c0onsider,
>
> HTH
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
>
>
>
> ------------------------------
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
> End of Tutor Digest, Vol 88, Issue 83
> *************************************
>



-- 
Thank you

Arun Kumar
http://clicknscroll.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110621/1fc2d034/attachment-0001.html>


More information about the Tutor mailing list