/home/nikos/public_html/cgi-bin/metrites.py in () 
    217                 template = htmldata + counter 
    218         elif page.endswith('.py'): 
=>  219                 htmldata = subprocess.check_output( '/home/nikos/public_html/cgi-bin/' + page ) 
    220                 template = htmldata.decode('utf-8').replace( 'Content-type: text/html; charset=utf-8', '' ) + counter 
    221                 
htmldata undefined, subprocess = <module 'subprocess' from '/opt/python3/lib/python3.3/subprocess.py'>, subprocess.check_output = <function check_output>, page = 'files.py' 
 /opt/python3/lib/python3.3/subprocess.py in check_output(timeout=None, *popenargs=('/home/nikos/public_html/cgi-bin/files.py',), **kwargs={}) 
    584         retcode = process.poll() 
    585         if retcode: 
=>  586             raise CalledProcessError(retcode, process.args, output=output) 
    587     return output 
    588 
global CalledProcessError = <class 'subprocess.CalledProcessError'>, retcode = 1, process = <subprocess.Popen object>, process.args = '/home/nikos/public_html/cgi-bin/files.py', output = b'Content-type: text/html; charset=utf-8\n\n<bod...n position 74: surrogates not allowed\n\n-->\n\n' 
CalledProcessError: Command '/home/nikos/public_html/cgi-bin/files.py' returned non-zero exit status 1 
      args = (1, '/home/nikos/public_html/cgi-bin/files.py') 
      cmd = '/home/nikos/public_html/cgi-bin/files.py' 
      output = b'Content-type: text/html; charset=utf-8\n\n<bod...n position 74: surrogates not allowed\n\n-->\n\n' 
      returncode = 1 
      with_traceback = <built-in method with_traceback of CalledProcessError object> 

Hello, this is my first post in this forum!
The above error message happened when i tried to rename one of my filenames from its greeklish name to greek characters.

files.py is a script that allows users to downlaod files from my server.
But i wish to present filenames in Greek and not in Greeklish

http://superhost.gr/?page=files.py
as it is now.

What can i do to make pth script accept greek filenames too?
Why does subprocess is complaining?

define the hmldata for all branches of the if statement.

It is defined, i just didnt post the while, if statemtn, here it is:

if cur.rowcount:
    counter = ''' <center>
                      <table border=2 cellpadding=2 bgcolor=black>
                      <td><font color=lime>Αριθμός Επισκεπτών</td>
                      <td><a href="http://superhost.gr/?show=log&page=%s"><font color=yellow> %d </td>
                  </table><br>
              ''' % (page, data[0])

    if page.endswith('.html'):
        with open('/home/nikos/public_html/' + page, encoding='utf-8') as f:
            htmldata = f.read()
        htmldata = htmldata % (quote, music)
        template = htmldata + counter
    elif page.endswith('.py'):
        htmldata = subprocess.check_output( '/home/nikos/public_html/cgi-bin/' + page )
        template = htmldata.decode('utf-8') + counter

    print( template )
Τη Κυριακή, 2 Ιουνίου 2013 10:01:50 π.μ. UTC+3, ο χρήστης Giorgos Tzampanakis έγραψε:

OK George, nd the rest fo the guys here it is the snippet of files.py responsible to print the greek filenames:

    for row in data:
        (url, hits, host, lastvisit) = row
        shorturl = url.replace( '/home/nikos/www/data/apps/', '' )
        lastvisit = lastvisit.strftime('%A %e %b, %H:%M')

        print('''
        <form method="get" action="cgi-bin/files.py">
            <tr>
                <td> <center> <input type="submit" name="shorturl" value="%s"> </td>
                <td> <center> <font color=yellow size=5> %s </td>
                <td> <center> <font color=orange size=4> %s </td>
                <td> <center> <font color=silver size=4> %s </td>
            </tr>
        </form>
        ''' % (shorturl, hits, host, lastvisit) )

and here is the the metrites.py snipper that calls files.py via subproccess to run:

    if page.endswith('.html'):
        with open('/home/nikos/public_html/' + page, encoding='utf-8') as f:
            htmldata = f.read()
        htmldata = htmldata % (quote, music)
        template = htmldata + counter
    elif page.endswith('.py'):
        htmldata = subprocess.check_output( '/home/nikos/public_html/cgi-bin/' + page )
        template = htmldata.decode('utf-8') + counter

    print( template ) 

Any ideas someone please?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.