Commit adb0fbc7 authored by Seblu's avatar Seblu

Also unicodify install subparser arguments

parent ec7a9ad6
......@@ -29,7 +29,6 @@ import argparse
import psutil
import socket
import sys
import locale
import installsystems
import installsystems.printer
import installsystems.tools as istools
......@@ -674,10 +673,7 @@ def main():
# init arg parser
arg_parser = arg_parser_init()
# encode command line arguments to utf-8
try:
args = [ unicode(x, encoding=locale.getpreferredencoding()) for x in sys.argv[1:]]
except UnicodeDecodeError as e:
raise ISError("Invalid character encoding in command line")
args = istools.argv()[1:]
# first partial parsing, to get early debug and config path
options = arg_parser.parse_known_args(args=args)[0]
# set early command line verbosity and color
......@@ -736,6 +732,7 @@ def main():
except Exception as e:
error(u"Unexpected error, please report it with debug enabled", exception=e)
# Entry point
if __name__ == '__main__':
main()
......@@ -981,9 +981,11 @@ class PackageImage(Image):
{"parser": extparser})
# call parser (again), with full options
arrow("Parsing command line")
# encode command line arguments to utf-8
args = istools.argv()[1:]
# Catch exception in custom argparse action
try:
args = parser.parse_args()
args = parser.parse_args(args=args)
except Exception as e:
raise ISError("Argument parser", e)
# run setup scripts
......
......@@ -670,3 +670,12 @@ def render_templates(target, context, tpl_ext=".istpl", force=False, keep=False)
os.chmod(file_path, st.st_mode)
if not keep:
os.unlink(tpl_path)
def argv():
'''
Return system argv after an unicode transformation with locale preference
'''
try:
return [unicode(x, encoding=locale.getpreferredencoding()) for x in sys.argv]
except UnicodeDecodeError as e:
raise ISError("Invalid character encoding in command line")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment