简体   繁体   中英

Encode exception from Python script called by Groovy script

I'm trying to execute Python script from Groovy script :)

Here is how i execute command:

def cmd = """guessit -j "$tmp" """
String output = cmd.execute()

Where $tmp contains file name passed as argument to groovy script. And i get Unicode error if there is non-ascii characters (i have russian letters in $tmp )

'ascii' codec can't encode characters in position 11-16: ordinal not in range(128)

encoding is UTF-8, -Dfile.encoding=UTF-8 is set

Python error log

command: guessit -j "Агенты А.Н.К.Л. (The Man from U.N.C.L.E.).2015.WEB-DLRip.mp4" 
Traceback (most recent call last):
  File "D:\Soft\Python27\Scripts\guessit-script.py", line 9, in <module>
    load_entry_point('guessit==2.0b3', 'console_scripts', 'guessit')()
  File "build\bdist.win32\egg\guessit\__main__.py", line 150, in main
  File "build\bdist.win32\egg\guessit\__main__.py", line 40, in guess_filename
UnicodeEncodeError: 'ascii' codec can't encode characters in position 11-16: ordinal not in range(128)

Python source is here https://github.com/wackou/guessit/blob/2.x/guessit/ main .py

if i call this command from cmd - there is no errors. OS is Windows 7. Language for non-Unicode is Russian

Whats wrong?

Resolved! SET PYTHONIOENCODING=utf-8 to set python encoding of stdin, stdout and stderr

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM