Inserting-embedding some html data at the end of a .py file

Michael Ross gmx at ross.cx
Wed Mar 6 00:19:03 CET 2013


On Tue, 05 Mar 2013 23:47:18 +0100, Νίκος Γκρ33κ <nikos.gr33k at gmail.com>  
wrote:

> Thank you very much! This is what i was looking for and here is my code  
> after receiving your help.
> So, with the command you provided to me i can actually run the .py  
> script ans save its output and then append from there!! Great!
>
> Here is my code now!
> ====================================
> 	if htmlpage.endswith('.html'):
> 		f = open( "/home/nikos/public_html/" + htmlpage )
> 		htmldata = f.read()
> 	elif htmlpage.endswith('.py'):
> 		htmldata = subprocess.check_output( open(  
> "/home/nikos/public_html/cgi-bin/" + htmlpage ) )
> 		
> 		
> 	counter = ''' <center><a href="mailto:support at superhost.gr"> <img  
> src="/data/images/mail.png"> </a>
> 		      <center><table border=2 cellpadding=2 bgcolor=black>
> 				<td><font color=lime>Αριθμός Επισκεπτών</td>
> 				<td><a href="http://superhost.gr/?show=stats"><font color=cyan> %d  
> </td>
> 		  ''' % data[0]
> 		
> 		
> 	template = htmldata + counter
> 	print ( template )
> =======================================
>
> But i'am getting this error:
> <type 'exceptions.AttributeError'>: 'module' object has no attribute  
> 'check_output'
>
> Why does it say it has no attribute?

Python version < 2.7 ?

And it's more along the lines of
	subprocess.check_output( '/home/nikos/.../' + htmlpage )
without "open".
Or even
	subprocess.check_output( [ '/your/python/interpreter', '/home/nikos/...'  
] )



More information about the Python-list mailing list