Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/tools/angle_tools.py
1693 views
1
#!/usr/bin/python2
2
#
3
# Copyright 2019 The ANGLE Project Authors. All rights reserved.
4
# Use of this source code is governed by a BSD-style license that can be
5
# found in the LICENSE file.
6
#
7
# angle_tools.py:
8
# Common functionality to scripts in angle/tools directory.
9
10
import os
11
import platform
12
import subprocess
13
14
is_windows = platform.system() == 'Windows'
15
is_linux = platform.system() == 'Linux'
16
17
18
def find_file_in_path(filename):
19
""" Finds |filename| by searching the environment paths """
20
path_delimiter = ';' if is_windows else ':'
21
for env_path in os.environ['PATH'].split(path_delimiter):
22
full_path = os.path.join(env_path, filename)
23
if os.path.isfile(full_path):
24
return full_path
25
raise Exception('Cannot find %s in environment' % filename)
26
27
28
def get_exe_name(file_name, windows_extension):
29
exe_name = file_name
30
if is_windows:
31
exe_name += windows_extension
32
return exe_name
33
34
35
def upload_to_google_storage(bucket, files):
36
upload_script = find_file_in_path('upload_to_google_storage.py')
37
upload_args = ['python', upload_script, '-b', bucket] + files
38
return subprocess.call(upload_args) == 0
39
40
41
def stage_google_storage_sha1(files):
42
git_exe = get_exe_name('git', '.bat')
43
git_exe = find_file_in_path(git_exe)
44
45
sha1_files = [f + '.sha1' for f in files]
46
return subprocess.call([git_exe, 'add'] + sha1_files) == 0
47
48