0

I have python code that calls Windows software (collada refinery) through command line. It works fine in the UK but does not work on a machine in China/Taiwan. When the filename/filepath contains any Chinese characters this refinery fails to find or open file.

Python code:

# somewhere in the code
subprocess.popen("refinery -i <inputfile.dae> -o <outfile.dae> -x polylists2triangles", shell=True).wait())

When this inputfile.dae (I have to give just the name and then refinery adds current directory absolute path to it and makes full absolute path of this input file name> weird but that's not the question) is read by refinery it throws error or not able to open the file.

I want to add checking in python so that if input file name/path contains Chinese or non-English characters then, it throws user defined exception.

ЯegDwight
  • 24,821
  • 10
  • 45
  • 52
abcdknocked abcd
  • 235
  • 1
  • 2
  • 5
  • Don't use `shell=True` unless the command must be interpreted by a shell which most of the time isn't true. – Dan D. Oct 15 '12 at 11:10
  • 1
    See [this question](http://stackoverflow.com/questions/2718196/find-all-chinese-text-in-a-string-using-python-and-regex). The answers give regexes to remove CJK characters, but of course it can also be used to detect them. – Junuxx Oct 15 '12 at 11:13

1 Answers1

0

Try to define the file encoding after the first interpreter line

# _*_ coding=utf-8 _*_

and save the file as utf-8 also

hbprotoss
  • 1,385
  • 10
  • 27