#!/usr/bin/python3
# ******************************************************************************
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
# licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#     http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# ******************************************************************************/
import sys
import signal
from signal import SIG_DFL
try:
    def sig_handler(signum, frame):
        print("\n", 'Exit command mode')
        sys.exit(0)

    signal.signal(signal.SIGINT, sig_handler)
    signal.signal(signal.SIGPIPE, SIG_DFL)
    from packageship.application.cli.cmd import main
except PermissionError as error:
    message = "Insufficient user permissions,{msg}".format(msg=str(error))
    print(message)
else:
    try:
        main()
    except Exception as error:
        print('Command execution error please try again ')
        print(error)
