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): |
dgarrett
2011/04/11 20:53:13
This method was left over from DJMM's changes, but
|
+ """ |
+ 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): |
+ file_obj = open(filename, 'r') |
+ else: |
+ file_obj = filename |
+ |
+ for line in file_obj: |
+ if line.startswith(varname + '='): |
+ pat = line.split('=', 1)[1] |
+ break |
+ return pat.strip() |
+ |
+ |
class RunCommandException(Exception): |
"""Raised when there is an error in OldRunCommand.""" |
def __init__(self, msg, cmd): |