[gm.py] Notify using print when notify-send is not supported

Bug:

Change-Id: I532e8894df288c81a71b08ca85742f2847f57191
Reviewed-on: https://chromium-review.googlesource.com/484339
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44781}
This commit is contained in:
Michael Lippautz 2017-04-21 14:15:38 +02:00 committed by Commit Bot
parent 2d856544e5
commit 7c87aeb188

View File

@ -142,11 +142,23 @@ def _Call(cmd, silent=False):
if not silent: print("# %s" % cmd)
return subprocess.call(cmd, shell=True)
def _Which(cmd):
for path in os.environ["PATH"].split(os.pathsep):
if os.path.exists(os.path.join(path, cmd)):
return os.path.join(path, cmd)
return None
def _Write(filename, content):
print("# echo > %s << EOF\n%sEOF" % (filename, content))
with open(filename, "w") as f:
f.write(content)
def _Notify(summary, body):
if _Which('notify-send') is not None:
_Call("notify-send '{}' '{}'".format(summary, body), silent=True)
else:
print("{} - {}".format(summary, body))
def GetPath(arch, mode):
subdir = "%s.%s" % (arch, mode)
return os.path.join(OUTDIR, subdir)
@ -302,11 +314,9 @@ def Main(argv):
for c in configs:
return_code += configs[c].RunTests()
if return_code == 0:
_Call("notify-send 'Done!' 'V8 compilation finished successfully.'",
silent=True)
_Notify('Done!', 'V8 compilation finished successfully.')
else:
_Call("notify-send 'Error!' 'V8 compilation finished with errors.'",
silent=True)
_Notify('Error!', 'V8 compilation finished with errors.')
return return_code
if __name__ == "__main__":