import shutil
import sys
import optparse
+import locale
################################################################
# Users of python modules should include this snippet
# Maybe guess encoding from LANG/LC_ALL/LC_CTYPE?
def encoded_write(f, s):
- f.write (s.encode (f.encoding or 'utf_8'))
+ f.write (s
+ .decode (sys.stderr.encoding or locale.getdefaultlocale()[1])
+ .encode (f.encoding or 'utf_8'))
# ugh, Python 2.5 optparse requires Unicode strings in some argument
# functions, and refuse them in some other places
os.system ("open http://python.org/download/")
sys.exit (2)
-# Modified version of the commands.mkarg(x), which always uses
+# Modified version of the commands.mkarg(x), which always uses
# double quotes (since Windows can't handle the single quotes:
def mkarg(x):
s = ' "'
log_file=None):
import subprocess
- show_progress= progress_p
+ show_progress= progress_p
name = command_name (cmd)
error_log_file = ''
system = subprocess_system
if sys.platform == 'mingw32':
-
+
## subprocess x-compile doesn't work.
system = ossystem_system
def print_environment ():
for (k,v) in os.environ.items ():
- sys.stderr.write ("%s=\"%s\"\n" % (k, v))
+ sys.stderr.write ("%s=\"%s\"\n" % (k, v))
class NonDentedHeadingFormatter (optparse.IndentedHelpFormatter):
def format_heading(self, heading):
def format_description(self, description):
return description
-def get_option_parser (*args, **kwargs):
+def get_option_parser (*args, **kwargs):
p = optparse.OptionParser (*args, **kwargs)
- p.formatter = NonDentedHeadingFormatter ()
+ p.formatter = NonDentedHeadingFormatter ()
return p