![]() |
Re: Inserting-embedding some html data at the end of a .py file
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@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? |
Re: Inserting-embedding some html data at the end of a .py file
On Tue, 05 Mar 2013 23:47:18 +0100, ΞΞ―ΞΊΞΏΟ ΞΞΊΟ33ΞΊ <nikos.gr33k@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@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/...' ] ) |
Re: Inserting-embedding some html data at the end of a .py file
htmldata = subprocess.check_output( '/home/nikos/public_html/cgi-bin/' + htmlpage )
htmldata = subprocess.check_output( ['/usr/bin/python', '/home/nikos/public_html/cgi-bin/' + htmlpage] ) Both of the above statemnts fail i'am afraid with the same error message. |
Re: Inserting-embedding some html data at the end of a .py file
htmldata = subprocess.check_output( '/home/nikos/public_html/cgi-bin/' + htmlpage )
htmldata = subprocess.check_output( ['/usr/bin/python', '/home/nikos/public_html/cgi-bin/' + htmlpage] ) Both of the above statemnts fail i'am afraid with the same error message. |
Re: Inserting-embedding some html data at the end of a .py file
On Wed, 06 Mar 2013 00:39:31 +0100, ΞΞ―ΞΊΞΏΟ ΞΞΊΟ33ΞΊ <nikos.gr33k@gmail.com>
wrote: > htmldata = subprocess.check_output( '/home/nikos/public_html/cgi-bin/' + > htmlpage ) > > htmldata = subprocess.check_output( ['/usr/bin/python', > '/home/nikos/public_html/cgi-bin/' + htmlpage] ) > > Both of the above statemnts fail i'am afraid with the same error message. check_output is available as of Python 2.7 I guess you are still on version 2.6 ? |
Re: Inserting-embedding some html data at the end of a .py file
Τη Τετάρτη, 6 Μαρτίου 2013 2:06:33 π.μ.UTC+2, ο χρήστης Michael Ross έγραψε:
> On Wed, 06 Mar 2013 00:39:31 +0100, Νίκος Γκρ33κ > > wrote: > > > > > htmldata = subprocess.check_output( '/home/nikos/public_html/cgi-bin/' + > > > htmlpage ) > > > > > > htmldata = subprocess.check_output( ['/usr/bin/python', > > > '/home/nikos/public_html/cgi-bin/' + htmlpage] ) > > > > > > Both of the above statemnts fail i'am afraid with the same error message. > check_output is available as of Python 2.7 > I guess you are still on version 2.6 ? Actually i'am runnign myu cgi script on my hostgator remote web hosting. How dod i check the version of python the server uses? |
Re: Inserting-embedding some html data at the end of a .py file
Τη Τετάρτη, 6 Μαρτίου 2013 2:06:33 π.μ.UTC+2, ο χρήστης Michael Ross έγραψε:
> On Wed, 06 Mar 2013 00:39:31 +0100, Νίκος Γκρ33κ > > wrote: > > > > > htmldata = subprocess.check_output( '/home/nikos/public_html/cgi-bin/' + > > > htmlpage ) > > > > > > htmldata = subprocess.check_output( ['/usr/bin/python', > > > '/home/nikos/public_html/cgi-bin/' + htmlpage] ) > > > > > > Both of the above statemnts fail i'am afraid with the same error message. > check_output is available as of Python 2.7 > I guess you are still on version 2.6 ? Actually i'am runnign myu cgi script on my hostgator remote web hosting. How dod i check the version of python the server uses? |
Re: Inserting-embedding some html data at the end of a .py file
Τη Τετάρτη, 6 Μαρτίου 2013 2:06:33 π.μ.UTC+2, ο χρήστης Michael Ross έγραψε:
> check_output is available as of Python 2.7 > > > > I guess you are still on version 2.6 ? Indeed! i just checked it's Python 2.6.6: /usr/bin/python and i have asked the linxu admins @ hostgator.com to update python. I trust when they update to v2.7 the script will automatically work! |
Re: Inserting-embedding some html data at the end of a .py file
Τη Τετάρτη, 6 Μαρτίου 2013 2:06:33 π.μ.UTC+2, ο χρήστης Michael Ross έγραψε:
> check_output is available as of Python 2.7 > > > > I guess you are still on version 2.6 ? Indeed! i just checked it's Python 2.6.6: /usr/bin/python and i have asked the linxu admins @ hostgator.com to update python. I trust when they update to v2.7 the script will automatically work! |
Re: Inserting-embedding some html data at the end of a .py file
Τη Τετάρτη, 6 Μαρτίου 2013 2:06:33 π.μ.UTC+2, ο χρήστης Michael Ross έγραψε:
> check_output is available as of Python 2.7 > I guess you are still on version 2.6 ? I can access each of these from my jailed shell user account without issue,and especially i try /usr/bin/python3 nikos@superhost.gr [~]# /usr/bin/python -V Python 2.6.6 nikos@superhost.gr [~]# /opt/python3/bin/python3 -V Python 3.2.3 nikos@superhost.gr [~]# /usr/bin/python3 -V Python 3.2.3 Problem is that when i change my shebang constructor to #!/sur/bin/python3 my '/cgi-bin/metrites.py' python cgi scripts produces an internal server error while with #!/sur/bin/python the script works. Any ideas as to why? I can post ocde if you want to. |
| All times are GMT. The time now is 07:22 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.