Changing filenames from Greeklish => Greek (subprocess compl

Changing filenames from Greeklish => Greek (subprocess compl

Postby NikosGr » Sat Jun 01, 2013 7:55 pm

Code: Select all
 
/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>


The above error message happened when i tried to reanme one of my filenames from

its greeklish name to greek charcters.

files.py is a script that allows users to downlaod fiels form my server.
But i wish to presnt filename sin 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?
NikosGr
 
Posts: 48
Joined: Thu Mar 28, 2013 6:31 pm
Location: Thessaloniki

Re: Changing filenames from Greeklish => Greek (subprocess c

Postby NikosGr » Sun Jun 02, 2013 3:07 pm

Code: Select all
 
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:

Code: Select all
    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 )
NikosGr
 
Posts: 48
Joined: Thu Mar 28, 2013 6:31 pm
Location: Thessaloniki


Return to Web Development

Who is online

Users browsing this forum: No registered users and 3 guests