| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 ''' | 5 ''' |
| 6 Utility functions for all things related to manipulating google play services | 6 Utility functions for all things related to manipulating google play services |
| 7 related files. | 7 related files. |
| 8 ''' | 8 ''' |
| 9 | 9 |
| 10 import argparse | 10 import argparse |
| 11 import filecmp | 11 import filecmp |
| 12 import json | 12 import json |
| 13 import logging | 13 import logging |
| 14 import os | 14 import os |
| 15 import re | 15 import re |
| 16 import sys | 16 import sys |
| 17 import zipfile | |
| 18 | 17 |
| 19 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir)) | 18 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir)) |
| 20 from devil.utils import cmd_helper | 19 from devil.utils import cmd_helper |
| 21 | 20 |
| 22 | 21 |
| 23 _XML_VERSION_NUMBER_PATTERN = re.compile( | 22 _XML_VERSION_NUMBER_PATTERN = re.compile( |
| 24 r'<integer name="google_play_services_version">(\d+)<\/integer>') | 23 r'<integer name="google_play_services_version">(\d+)<\/integer>') |
| 25 | 24 |
| 26 | 25 |
| 27 class DefaultsRawHelpFormatter(argparse.ArgumentDefaultsHelpFormatter, | 26 class DefaultsRawHelpFormatter(argparse.ArgumentDefaultsHelpFormatter, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 def MakeLocalCommit(repo_root, files_to_commit, message): | 104 def MakeLocalCommit(repo_root, files_to_commit, message): |
| 106 '''Makes a local git commit.''' | 105 '''Makes a local git commit.''' |
| 107 | 106 |
| 108 logging.debug('Staging files (%s) for commit.', files_to_commit) | 107 logging.debug('Staging files (%s) for commit.', files_to_commit) |
| 109 if cmd_helper.Call(['git', 'add'] + files_to_commit, cwd=repo_root) != 0: | 108 if cmd_helper.Call(['git', 'add'] + files_to_commit, cwd=repo_root) != 0: |
| 110 raise Exception('The local commit failed.') | 109 raise Exception('The local commit failed.') |
| 111 | 110 |
| 112 logging.debug('Committing.') | 111 logging.debug('Committing.') |
| 113 if cmd_helper.Call(['git', 'commit', '-m', message], cwd=repo_root) != 0: | 112 if cmd_helper.Call(['git', 'commit', '-m', message], cwd=repo_root) != 0: |
| 114 raise Exception('The local commit failed.') | 113 raise Exception('The local commit failed.') |
| 115 | |
| 116 | |
| 117 def ZipDir(output, base_dir): | |
| 118 '''Creates a zip file from a directory.''' | |
| 119 | |
| 120 base = os.path.join(base_dir, os.pardir) | |
| 121 with zipfile.ZipFile(output, 'w') as out_file: | |
| 122 for root, _, files in os.walk(base_dir): | |
| 123 for in_file in files: | |
| 124 out_file.write(os.path.join(root, in_file), base) | |
| OLD | NEW |