Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(371)

Unified Diff: lib/cros_build_lib.py

Issue 3591002: Add ability to run smoke_Suite on x86-pre-flight-queue. (Closed) Base URL: http://git.chromium.org/git/crosutils.git
Patch Set: Fix no_graphics Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bin/cbuildbot_config.py ('k') | lib/cros_vm_lib.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/cros_build_lib.py
diff --git a/lib/cros_build_lib.py b/lib/cros_build_lib.py
index a0cd73c6edaac26c2324c7af158a5c00d7bf762d..71c908648f764575433251a16b45ff181df03f2e 100644
--- a/lib/cros_build_lib.py
+++ b/lib/cros_build_lib.py
@@ -4,11 +4,21 @@
"""Common python commands used by various build scripts."""
+import inspect
+import os
import subprocess
import sys
_STDOUT_IS_TTY = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
+# TODO(sosa): Move logging to logging module.
+
+def GetCallerName():
+ """Returns the name of the calling module with __main__."""
+ top_frame = inspect.stack()[-1][0]
+ return os.path.basename(top_frame.f_code.co_filename)
+
+
def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
exit_code=False, redirect_stdout=False, redirect_stderr=False,
cwd=None, input=None, enter_chroot=False):
@@ -44,7 +54,8 @@ def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
# Print out the command before running.
if print_cmd:
- Info('RunCommand: %s' % ' '.join(cmd))
+ Info('PROGRAM(%s) -> RunCommand: %s in dir %s' %
+ (GetCallerName(), ' '.join(cmd), cwd))
try:
proc = subprocess.Popen(cmd, cwd=cwd, stdin=stdin,
@@ -56,7 +67,7 @@ def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
if not error_ok and proc.returncode:
raise Exception('Command "%s" failed.\n' % (' '.join(cmd)) +
(error_message or error or output or ''))
- except Exception,e:
+ except Exception, e:
if not error_ok:
raise
else:
« no previous file with comments | « bin/cbuildbot_config.py ('k') | lib/cros_vm_lib.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698