Chromium Code Reviews| Index: lib/cros_build_lib.py |
| diff --git a/lib/cros_build_lib.py b/lib/cros_build_lib.py |
| index 8728fe3fb734b99ba3738c5520935e42200a92c2..739bdf98f723eb7f0fabb7b14c59ef2f15e68ac0 100644 |
| --- a/lib/cros_build_lib.py |
| +++ b/lib/cros_build_lib.py |
| @@ -95,7 +95,10 @@ def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None, |
| # Print out the command before running. |
| if print_cmd: |
| - Info('RunCommand: %s' % cmd_str) |
| + if cwd: |
| + Info('RunCommand: %s in %s' % (cmd_str, cwd)) |
| + else: |
| + Info('RunCommand: %s' % cmd_str) |
| cmd_result.cmd = cmd |
| try: |
| @@ -298,6 +301,24 @@ def GetCallerName(): |
| return os.path.basename(top_frame.f_code.co_filename) |
| +def GetValueFromFile(filename, varname): |
| + """ |
|
sosa
2011/04/11 19:03:54
One line short docstring on first line i.e. Return
|
| + Given a NAME, return the VALUE out of a file. (NAME=VALUE) |
| + or the awk equivalent: |
| + $ awk -F= '/varname=/ {print $2}' filename |
| + """ |
| + if os.path.isfile(filename): |
|
sosa
2011/04/11 19:03:54
filename can be an obj or file? I'd think it be c
|
| + file_obj = open(filename, 'r') |
| + else: |
| + file_obj = filename |
| + |
| + for line in file_obj: |
| + if line.startswith(varname + '='): |
| + pat = line.split('=', 1)[1] |
| + break |
|
sosa
2011/04/11 19:03:54
extra line after
|
| + return pat.strip() |
|
sosa
2011/04/11 19:03:54
File remains opened :(
|
| + |
| + |
| class RunCommandException(Exception): |
| """Raised when there is an error in OldRunCommand.""" |
| def __init__(self, msg, cmd): |