| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium OS 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 """Utility functions shared between files in the chromite shell.""" | 5 """Utility functions shared between files in the chromite shell.""" |
| 6 | 6 |
| 7 | 7 |
| 8 # Python imports | 8 # Python imports |
| 9 import ConfigParser | 9 import ConfigParser |
| 10 import cPickle | 10 import cPickle |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 args: All other arguments will be passed to the function as is. | 297 args: All other arguments will be passed to the function as is. |
| 298 kwargs: All other arguments will be passed to the function as is. | 298 kwargs: All other arguments will be passed to the function as is. |
| 299 """ | 299 """ |
| 300 # Make sure that the chroot exists... | 300 # Make sure that the chroot exists... |
| 301 chroot_dir = GetChrootAbsDir(chroot_config) | 301 chroot_dir = GetChrootAbsDir(chroot_config) |
| 302 if not DoesChrootExist(chroot_config): | 302 if not DoesChrootExist(chroot_config): |
| 303 cros_lib.Die( | 303 cros_lib.Die( |
| 304 'Chroot dir does not exist; try the "build host" command.\n %s.' % | 304 'Chroot dir does not exist; try the "build host" command.\n %s.' % |
| 305 chroot_dir) | 305 chroot_dir) |
| 306 | 306 |
| 307 cros_lib.Info('ENTERING THE CHROOT') |
| 308 |
| 307 # Save state to a temp file (inside the chroot!) using pickle. | 309 # Save state to a temp file (inside the chroot!) using pickle. |
| 308 tmp_dir = os.path.join(chroot_dir, 'tmp') | 310 tmp_dir = os.path.join(chroot_dir, 'tmp') |
| 309 state_file = tempfile.NamedTemporaryFile(prefix='chromite', dir=tmp_dir) | 311 state_file = tempfile.NamedTemporaryFile(prefix='chromite', dir=tmp_dir) |
| 310 try: | 312 try: |
| 311 cPickle.dump((func, args, kwargs), state_file, cPickle.HIGHEST_PROTOCOL) | 313 cPickle.dump((func, args, kwargs), state_file, cPickle.HIGHEST_PROTOCOL) |
| 312 state_file.flush() | 314 state_file.flush() |
| 313 | 315 |
| 314 # Translate temp file name into a chroot path... | 316 # Translate temp file name into a chroot path... |
| 315 chroot_state_path = os.path.join('/tmp', os.path.basename(state_file.name)) | 317 chroot_state_path = os.path.join('/tmp', os.path.basename(state_file.name)) |
| 316 | 318 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 func = getattr(obj, method) | 376 func = getattr(obj, method) |
| 375 | 377 |
| 376 func(*args, **kwargs) # pylint: disable=W0142 | 378 func(*args, **kwargs) # pylint: disable=W0142 |
| 377 | 379 |
| 378 # Return True to tell main() that it should exit. | 380 # Return True to tell main() that it should exit. |
| 379 return True | 381 return True |
| 380 else: | 382 else: |
| 381 # Return False to tell main() that we didn't find the --resume-state | 383 # Return False to tell main() that we didn't find the --resume-state |
| 382 # argument and that it should do normal arugment parsing. | 384 # argument and that it should do normal arugment parsing. |
| 383 return False | 385 return False |
| OLD | NEW |