Exemplo n.º 1
0
def ensure_uamqp(config, yes=False, repair=False):
    if get_uamqp_ext_version(
            config) != EVENT_LIB[1] or repair or not test_import(EVENT_LIB[0]):
        if not yes:
            input_txt = (
                'Dependency update required for IoT extension version: {}. {}'
                'Updated dependency must be compatible with {} {}. '
                'Continue? (y/n) -> ').format(VERSION, linesep, EVENT_LIB[0],
                                              EVENT_LIB[1])
            i = input(input_txt)
            if i.lower() != 'y':
                sys.exit('User has declined update...')

        six.print_('Updating required dependency...')
        with HomebrewPipPatch():
            # The version range defined in this custom_version parameter should be stable
            if install(EVENT_LIB[0],
                       custom_version='>={},<{}'.format(
                           EVENT_LIB[1], EVENT_LIB[2])):
                update_uamqp_ext_version(config, EVENT_LIB[1])
                six.print_(
                    'Update appears to have worked. Executing command...')
            else:
                sys.exit('Failure updating {} {}. Aborting...'.format(
                    EVENT_LIB[0], EVENT_LIB[1]))
Exemplo n.º 2
0
def ensure_uamqp(config, yes=False, repair=False):
    if get_uamqp_ext_version(config) != EVENT_LIB[1] or repair or not test_import(EVENT_LIB[0]):
        if not yes:
            input_txt = ('Dependency update ({} {}) required for IoT extension version: {}. {}'
                         'Continue? (y/n) -> ').format(EVENT_LIB[0], EVENT_LIB[1], VERSION, linesep)
            i = input(input_txt)
            if i.lower() != 'y':
                sys.exit('User has declined update...')

        print('Updating required dependency...')
        with HomebrewPipPatch():
            # The version range defined in this custom_version parameter should be stable
            try:
                install(EVENT_LIB[0], compatible_version='{}'.format(EVENT_LIB[1]))
                update_uamqp_ext_version(config, EVENT_LIB[1])
                print('Update complete. Executing command...')
            except RuntimeError as e:
                print('Failure updating {}. Aborting...'.format(EVENT_LIB[0]))
                raise CLIError(e)
Exemplo n.º 3
0
    def test_pip_install(self, subprocess_scenario, install_type, package_name,
                         expected):
        from azext_iot.common.pip import install
        from sys import executable

        install(package_name, **install_type)

        assert subprocess_scenario.check_output.call_count == 1

        call = subprocess_scenario.check_output.call_args[0][0]

        assert call == [
            executable,
            "-m",
            "pip",
            "--disable-pip-version-check",
            "--no-cache-dir",
            "install",
            "-U",
            "--target",
            get_extension_path(EXTENSION_NAME),
            expected,
        ]
Exemplo n.º 4
0
    def test_pip_error(self, subprocess_error):
        from azext_iot.common.pip import install

        with pytest.raises(RuntimeError):
            install("uamqp")