Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Generic utilities for all python scripts.""" | 5 """Generic utilities for all python scripts.""" |
| 6 | 6 |
| 7 import atexit | 7 import atexit |
| 8 import httplib | 8 import httplib |
| 9 import os | 9 import os |
| 10 import signal | 10 import signal |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 | 32 |
| 33 | 33 |
| 34 def IsLinux(): | 34 def IsLinux(): |
| 35 return sys.platform.startswith('linux') | 35 return sys.platform.startswith('linux') |
| 36 | 36 |
| 37 | 37 |
| 38 def IsMac(): | 38 def IsMac(): |
| 39 return sys.platform.startswith('darwin') | 39 return sys.platform.startswith('darwin') |
| 40 | 40 |
| 41 | 41 |
| 42 def GetAbsolutePathOfUserPath(user_path): | |
| 43 """Expand the given |user_path| (like "~/file") and return its absolute path. | |
| 44 """ | |
| 45 if not user_path: | |
|
craigdh
2014/01/29 18:47:35
The empty string will cause this to return None. I
stgao
2014/01/29 19:40:27
Nice catch.
Done.
| |
| 46 return None | |
| 47 return os.path.abspath(os.path.expanduser(user_path)) | |
| 48 | |
| 49 | |
| 42 def _DeleteDir(path): | 50 def _DeleteDir(path): |
| 43 """Deletes a directory recursively, which must exist.""" | 51 """Deletes a directory recursively, which must exist.""" |
| 44 # Don't use shutil.rmtree because it can't delete read-only files on Win. | 52 # Don't use shutil.rmtree because it can't delete read-only files on Win. |
| 45 for root, dirs, files in os.walk(path, topdown=False): | 53 for root, dirs, files in os.walk(path, topdown=False): |
| 46 for name in files: | 54 for name in files: |
| 47 filename = os.path.join(root, name) | 55 filename = os.path.join(root, name) |
| 48 os.chmod(filename, stat.S_IWRITE) | 56 os.chmod(filename, stat.S_IWRITE) |
| 49 os.remove(filename) | 57 os.remove(filename) |
| 50 for name in dirs: | 58 for name in dirs: |
| 51 os.rmdir(os.path.join(root, name)) | 59 os.rmdir(os.path.join(root, name)) |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 | 192 |
| 185 | 193 |
| 186 def AddLink(label, url): | 194 def AddLink(label, url): |
| 187 """Adds a link with name |label| linking to |url| to current buildbot step. | 195 """Adds a link with name |label| linking to |url| to current buildbot step. |
| 188 | 196 |
| 189 Args: | 197 Args: |
| 190 label: A string with the name of the label. | 198 label: A string with the name of the label. |
| 191 url: A string of the URL. | 199 url: A string of the URL. |
| 192 """ | 200 """ |
| 193 print '@@@STEP_LINK@%s@%s@@@' % (label, url) | 201 print '@@@STEP_LINK@%s@%s@@@' % (label, url) |
| OLD | NEW |