File: install_modules.py

package info (click to toggle)
azure-cli 2.82.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,359,416 kB
  • sloc: python: 1,910,381; sh: 1,343; makefile: 406; cs: 145; javascript: 74; sql: 37; xml: 21
file content (35 lines) | stat: -rw-r--r-- 1,162 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
27
28
29
30
31
32
33
34
35
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import sys
import os
import subprocess
import automation.utilities.path as autmation_path

INSTALL_COMMAND = 'python -m pip install -e {}'


def install_modules():
    all_modules = list(autmation_path.get_command_modules_paths())

    print('Installing command modules')
    print('Modules: {}'.format(', '.join(name for name, _ in all_modules)))
    failures = []

    for name, path in all_modules:
        try:
            subprocess.check_call(INSTALL_COMMAND.format(path).split())
        except subprocess.CalledProcessError as err:
            # exit code is not zero
            failures.append('Failed to install {}. Error message: {}'.format(name, err.output))

    for f in failures:
        print(f)

    return not any(failures)


if __name__ == '__main__':
    sys.exit(0 if install_modules() else 1)