From d6a55bf4d9b0f00b9da5304dff35a6edd6f9b452 Mon Sep 17 00:00:00 2001 From: likeelli Date: Tue, 24 Feb 2026 15:52:09 +0800 Subject: [PATCH] =?UTF-8?q?--story=3D126434218=20=E3=80=90L3=E3=80=91?= =?UTF-8?q?=E4=BD=BF=E7=94=A8tccli=E6=8A=A5=E9=94=99=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=86=97=E4=BD=99=EF=BC=8C=E9=9C=80=E8=A6=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tccli/main.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tccli/main.py b/tccli/main.py index 872d371c19..0d05e8f223 100644 --- a/tccli/main.py +++ b/tccli/main.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import _locale + _locale._getdefaultlocale = (lambda *args: ['zh_CN', 'utf8']) import io @@ -14,6 +15,7 @@ # python2 doesn't support cp65001 codec if getattr(sys.stdin, 'encoding', 'utf-8') == "cp65001": import codecs + codecs.register(lambda name: codecs.lookup('utf-8') if name == 'cp65001' else None) reload(sys) # Python 2.7 @@ -22,9 +24,11 @@ try: sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') from importlib import reload # Python 3.4+ + reload(sys) except ImportError: from imp import reload # Python 3.0 - 3.3 + reload(sys) from tccli.command import CLICommand from tccli import __version__ @@ -75,9 +79,13 @@ def main(): log.exception(e) return 255 except TencentCloudSDKException as e: - sys.stderr.write("usage: %s\n" % USAGE) - sys.stderr.write(str(e)) - sys.stderr.write("\n") + if hasattr(e, 'requestId') and e.requestId: + sys.stderr.write(str(e)) + sys.stderr.write("\n") + else: + sys.stderr.write("usage: %s\n" % USAGE) + sys.stderr.write(str(e)) + sys.stderr.write("\n") log.error(e) return 255 except Exception as e: @@ -90,4 +98,3 @@ def main(): if __name__ == "__main__": main() -