File: pip_helper.py

package info (click to toggle)
azure-devops-cli-extension 1.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,384 kB
  • sloc: python: 160,782; xml: 198; makefile: 56; sh: 51
file content (26 lines) | stat: -rw-r--r-- 1,125 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from knack.log import get_logger
from knack.util import CLIError

from azure.cli.core.extension.operations import _run_pip
from azure.cli.core.extension import get_extension_path

logger = get_logger(__name__)


def install_keyring():
    _install_package('keyring~=17.1.1')


def _install_package(package_name):
    logger.debug('installing %s', package_name)
    extensionPath = get_extension_path('azure-devops')
    pip_args = ['install', package_name, '--target', extensionPath]
    pip_status_code = _run_pip(pip_args)  # pylint: disable=protected-access
    if pip_status_code > 0:
        raise CLIError('An error occurred. Pip failed with status code {} for package {}. '
                       'Use --debug for more information.'.format(pip_status_code, package_name))