Beispiel #1
0
def main():
    try:
        cli_version = __version__.rsplit(".", 1)[0]
        if sdkVersion < cli_version:
            print(
                "Version is inconsistent, python sdk version:%s tccli version:%s"
                % (sdkVersion, __version__))
            return
        if len(sys.argv) < 2:
            print(ErrorMsg.INVALID_CMD % "too few arguments")
            return
        services = Services.service_get_list()

        c = Configure(services)
        c.init_configures()

        command = NiceCommand("tccli", tccli_action)
        command.reg_opt(OptionalsDefine.Help, "bool")
        command.reg_opt(OptionalsDefine.CliVersion, "bool")

        if sys.argv[1] == "configure":
            config = Configure(services)
            config.register_arg(command)
        elif sys.argv[1] in services:
            Services.services_register_arg(command, sys.argv[1])

        command.parse(sys.argv[1:])

    except Exception as err:
        print("tccli: " + str(err))
Beispiel #2
0
def main():
    cli_version = __version__.rsplit(".", 1)[0]
    if sdkVersion < cli_version:
        sys.stderr.write(
            "Version is inconsistent, python sdk version:%s tccli version:%s" %
            (sdkVersion, __version__))
        return
    try:
        log.info("tccli %s" % ' '.join(sys.argv[1:]))
        CLICommand()()
    except UnknownArgumentError as e:
        sys.stderr.write("usage: %s\n" % USAGE)
        sys.stderr.write(str(e))
        sys.stderr.write("\n")
        log.exception(e)
        return
    except ConfigurationError as e:
        sys.stderr.write("usage: %s\n" % USAGE)
        sys.stderr.write(str(e))
        sys.stderr.write("\n")
        log.exception(e)
        return
    except NoRegionError as e:
        msg = ('%s You can configure your region by running '
               '"tccli configure".' % e)
        sys.stderr.write(msg)
        sys.stderr.write('\n')
        log.exception(e)
        return
    except NoCredentialsError as e:
        msg = ('%s. You can configure your credentials by running '
               '"tccli configure".' % e)
        sys.stderr.write(msg)
        sys.stderr.write('\n')
        log.exception(e)
        return
    except KeyboardInterrupt:
        sys.stdout.write("\n")
        return
    except ClientError as e:
        sys.stderr.write("\n")
        sys.stderr.write(six.text_type(e))
        sys.stderr.write("\n")
        log.exception(e)
        return
    except TencentCloudSDKException as e:
        sys.stderr.write("usage: %s\n" % USAGE)
        sys.stderr.write(str(e))
        sys.stderr.write("\n")
        log.error(e)
        return
    except Exception as e:
        sys.stderr.write("usage: %s\n" % USAGE)
        sys.stderr.write(str(e))
        sys.stderr.write("\n")
        log.exception(e)
        return
def main():
    vinput = None
    if not PY2:
        vinput = input
    else:
        vinput = raw_input
    cli_version = __version__.rsplit(".", 1)[0]
    dep_sdk = "tencentcloud-sdk-python-intl-en >= %s" % cli_version
    if SDK_VERSION is not None:
        if SDK_VERSION < cli_version:
            answer = None
            prompt = ("The current python sdk version (%s) is "
                      "too low and we will update to %s(yes/no):") % (
                          SDK_VERSION, cli_version)
            answer = vinput(prompt)
            if answer not in ["yes", "YES", "Yes"]:
                print("tccli install failed")
                return
    setup(
        name='tccli-intl-en',
        install_requires=[dep_sdk, "jmespath==0.10.0", "six==1.16.0"],
        version=VERSION,
        description='Universal Command Line Environment for Tencent Cloud',
        long_description=open('README.rst').read(),
        author='Tencent Cloud',
        url='https://github.com/TencentCloud/tencentcloud-cli-intl-en.git',
        maintainer_email="*****@*****.**",
        packages=find_packages(),
        include_package_data=True,
        platforms=['unix', 'linux', 'win64'],
        scripts=[],
        py_modules=['tccli'],
        entry_points={
            'console_scripts': [
                'tccli = tccli.main:main',
                'tccli_completer  = tccli.completer:complete',
            ]
        },
        classifiers=[
            'Development Status :: 5 - Production/Stable',
            'Intended Audience :: Developers',
            'License :: OSI Approved :: Apache Software License',
            'Programming Language :: Python',
            'Programming Language :: Python :: 2.7',
            'Programming Language :: Python :: 3',
            'Programming Language :: Python :: 3.1',
            'Programming Language :: Python :: 3.2',
            'Programming Language :: Python :: 3.3',
            'Programming Language :: Python :: 3.4',
            'Programming Language :: Python :: 3.5',
            'Programming Language :: Python :: 3.6',
        ],
    )