Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: Inserting-embedding some html data at the end of a .py file (http://www.velocityreviews.com/forums/t958394-re-inserting-embedding-some-html-data-at-the-end-of-a-py-file.html)

Νίκος Γκρ33κ 03-05-2013 10:47 PM

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?

Michael Ross 03-05-2013 11:19 PM

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/...'
] )

Νίκος Γκρ33κ 03-05-2013 11:39 PM

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.

Νίκος Γκρ33κ 03-05-2013 11:39 PM

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.

Michael Ross 03-06-2013 12:06 AM

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 ?



Νίκος Γκρ33κ 03-06-2013 06:12 AM

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?

Νίκος Γκρ33κ 03-06-2013 06:12 AM

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?

Νίκος Γκρ33κ 03-06-2013 07:48 AM

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!

Νίκος Γκρ33κ 03-06-2013 07:48 AM

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!

Νίκος Γκρ33κ 03-06-2013 11:18 PM

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.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57