Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions tccli/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

import _locale

_locale._getdefaultlocale = (lambda *args: ['zh_CN', 'utf8'])

import io
Expand All @@ -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
Expand All @@ -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__
Expand Down Expand Up @@ -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:
Expand All @@ -90,4 +98,3 @@ def main():

if __name__ == "__main__":
main()