3 # Copyright (c) 2014 Intel Corporation. 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 # pylint: disable=F0401
17 if os.path.exists(path):
21 def AllArchitectures():
25 def RunCommand(command, verbose=False, shell=False):
26 """Runs the command list, print the output, and propagate its result."""
27 proc = subprocess.Popen(command, stdout=subprocess.PIPE,
28 stderr=subprocess.STDOUT, shell=shell)
30 output = proc.communicate()[0]
31 result = proc.returncode
33 print(output.decode("utf-8").strip())
35 print ('Command "%s" exited with non-zero exit code %d'
36 % (' '.join(command), result))
38 return output.decode("utf-8")
44 """Get the version of this python tool."""
45 version_str = 'Crosswalk app packaging tool version is '
46 file_handle = open(path, 'r')
47 src_content = file_handle.read()
48 version_nums = re.findall(r'\d+', src_content)
49 version_str += ('.').join(version_nums)
54 def CreateAndCopyDir(src_dir, dest_dir, delete_if_exists=False):
55 if not os.path.isdir(src_dir):
57 # create path, except last directory (handled by copytree)
58 pre_dest_dir = os.path.dirname(dest_dir)
59 if not os.path.isdir(pre_dest_dir):
61 os.makedirs(pre_dest_dir) # throws exception on error
64 if os.path.exists(dest_dir):
66 shutil.rmtree(dest_dir)
69 shutil.copytree(src_dir, dest_dir)