def copy_sqltoolsservice()

in mssqlscripter/mssqltoolsservice/external.py [0:0]


def copy_sqltoolsservice(platform):
    """
        For each supported platform, build a universal wheel.
    """
    # Clean up dangling directories if previous run was interrupted.
    utility.clean_up(directory=TARGET_DIRECTORY)

    if not platform or platform not in SUPPORTED_PLATFORMS:
        print('{} is not supported.'.format(platform))
        print('Please provide a valid platform flag.' +
              '[win32, win_amd64, manylinux1_x86_64, macosx_10_11_intel]')
        sys.exit(1)

    copy_file_path = SUPPORTED_PLATFORMS[platform]

    print('Sqltoolsservice archive found at {}'.format(copy_file_path))
    if copy_file_path.endswith('tar.gz'):
        compressed_file = tarfile.open(name=copy_file_path, mode='r:gz')
    elif copy_file_path.endswith('.zip'):
        compressed_file = zipfile.ZipFile(copy_file_path)

    if not os.path.exists(TARGET_DIRECTORY):
        os.makedirs(TARGET_DIRECTORY)

    print(u'Bin placing sqltoolsservice for this platform: {}.'.format(platform))
    print(u'Extracting files from {}'.format(copy_file_path))
    compressed_file.extractall(TARGET_DIRECTORY)