diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2017-02-24 20:49:51 +0100 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2017-02-24 20:49:51 +0100 |
commit | f6ab3d8e9cc90a5bc028334ca96001a612a3e001 (patch) | |
tree | 3e789d5789ff9dfda0f8fb0fbf7926458c792e86 | |
parent | b59b677c9b13483aac72b15f4f797863d841d958 (diff) |
osmoutil: open /dev/null only once
Change-Id: Ic6da34f6c4c5cd3b0786788f4e38c9c6248fca1b
-rwxr-xr-x | osmopy/osmoutil.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/osmopy/osmoutil.py b/osmopy/osmoutil.py index 7b20043..01f74cc 100755 --- a/osmopy/osmoutil.py +++ b/osmopy/osmoutil.py @@ -23,9 +23,14 @@ import time """Run a command, with stdout and stderr directed to devnull""" +devnull = None def popen_devnull(cmd, verbose=True): - devnull = open(os.devnull, 'w') + global devnull + if devnull is None: + if verbose: + print "Opening /dev/null" + devnull = open(os.devnull, 'w') if verbose: print "Launching: PWD=%s %s" % (os.getcwd(), ' '.join([repr(c) for c in cmd])) return subprocess.Popen(cmd, stdout=devnull, stderr=devnull) |