Changing filenames from Greeklish => Greek (subprocess complain)

Νικόλαος Κούρας nikos.gr33k at gmail.com
Sun Jun 2 02:02:59 EDT 2013


Τη Σάββατο, 1 Ιουνίου 2013 6:44:36 μ.μ. UTC+3, ο χρήστης Νικόλαος Κούρας έγραψε:
> /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?

i tried encode and decode

elif page.endswith('.py'):
    htmldata = subprocess.check_output( '/home/nikos/public_html/cgi-bin/' + page )
    template = htmldata.decode('utf-8') + counter

bu still same error when i rename a filename with greek letters.

Any ideas? is this a bug?



More information about the Python-list mailing list