This repository has been archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 149
/
utility.py
72 lines (58 loc) · 2.02 KB
/
utility.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
from __future__ import print_function
from subprocess import check_call, CalledProcessError
import os
import platform
import shutil
import sys
ROOT_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..'))
MSSQLSCRIPTER_DIST_DIRECTORY = os.path.abspath(
os.path.join(os.path.abspath(__file__), '..', 'dist'))
MSSQLSCRIPTER_BUILD_DIRECTORY = os.path.abspath(
os.path.join(os.path.abspath(__file__), '..', 'build'))
def exec_command(command, directory, continue_on_error=True):
"""
Execute command.
"""
try:
check_call(command.split(), cwd=directory)
except CalledProcessError as err:
# Continue execution in scenarios where we may be bulk command execution.
print(err, file=sys.stderr)
if not continue_on_error:
sys.exit(1)
else:
pass
def cleaun_up_egg_info_sub_directories(directory):
for f in os.listdir(directory):
if f.endswith(".egg-info"):
clean_up(os.path.join(directory, f))
def clean_up(directory):
"""
Delete directory.
"""
try:
shutil.rmtree(directory)
except Exception:
# Ignored, directory may not exist which is fine.
pass
def get_current_platform():
"""
Get current platform name.
"""
system = platform.system()
arch = platform.architecture()[0]
run_time_id = None
if system == 'Windows':
if arch == '32bit':
run_time_id = 'win32'
elif arch == '64bit':
run_time_id = 'win_amd64'
elif system == 'Darwin':
run_time_id = 'macosx_10_11_intel'
elif system == 'Linux':
run_time_id = 'manylinux1_x86_64'
return run_time_id