Feature/stdout fix (#84)
* Adding logic to set PYTHONIOENCODING and clean up. * Adding PYTHONIOENCODING env var to sh script. * Removing debug print statement. * Removing unused os import.
This commit is contained in:
Родитель
e5ce8899b0
Коммит
3068573353
|
@ -8,6 +8,9 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
|
||||||
done
|
done
|
||||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||||
|
|
||||||
|
# Set the python io encoding to UTF-8 by default if not set.
|
||||||
|
if [ -z ${PYTHONIOENCODING+x} ]; then export PYTHONIOENCODING=utf8; fi
|
||||||
|
|
||||||
export PYTHONPATH="${DIR}:${PYTHONPATH}"
|
export PYTHONPATH="${DIR}:${PYTHONPATH}"
|
||||||
|
|
||||||
python -m mssqlscripter "$@"
|
python -m mssqlscripter "$@"
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
@echo off
|
@echo off
|
||||||
setlocal
|
setlocal
|
||||||
|
REM Set the python io encoding to UTF-8 by default if not set.
|
||||||
|
IF "%PYTHONIOENCODING%"=="" (
|
||||||
|
SET PYTHONIOENCODING="UTF-8"
|
||||||
|
)
|
||||||
SET PYTHONPATH=%~dp0;%PYTHONPATH%
|
SET PYTHONPATH=%~dp0;%PYTHONPATH%
|
||||||
python -m mssqlscripter %*
|
python -m mssqlscripter %*
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ logger = logging.getLogger(u'mssqlscripter.main')
|
||||||
def main(args):
|
def main(args):
|
||||||
"""
|
"""
|
||||||
Main entry point to mssql-scripter.
|
Main entry point to mssql-scripter.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
scripterlogging.initialize_logger()
|
scripterlogging.initialize_logger()
|
||||||
logger.info('Python Information :{}'.format(sys.version_info))
|
logger.info('Python Information :{}'.format(sys.version_info))
|
||||||
|
@ -96,13 +95,6 @@ def main(args):
|
||||||
if temp_file_path:
|
if temp_file_path:
|
||||||
with io.open(parameters.FilePath, encoding=u'utf-16') as script_file:
|
with io.open(parameters.FilePath, encoding=u'utf-16') as script_file:
|
||||||
for line in script_file.readlines():
|
for line in script_file.readlines():
|
||||||
# If piping, stdout encoding is none in python 2 which resolves to 'ascii'.
|
|
||||||
# If it is not none then the user has specified a custom
|
|
||||||
# encoding.
|
|
||||||
if not sys.stdout.encoding:
|
|
||||||
# We are piping and the user is using the default encoding,
|
|
||||||
# so encode to utf8.
|
|
||||||
line = line.encode(u'utf-8')
|
|
||||||
sys.stdout.write(line)
|
sys.stdout.write(line)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче