]> granicus.if.org Git - python/commitdiff
If the executable doesn't exist, there's no reason to try to start it.
authorNeal Norwitz <nnorwitz@gmail.com>
Sat, 29 Jul 2006 20:20:52 +0000 (20:20 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sat, 29 Jul 2006 20:20:52 +0000 (20:20 +0000)
This prevents garbage about command not found being printed on Solaris.

Lib/uuid.py

index b0afd945c1047d6b462008e4fe2420720ac77364..a6446a16f9fc76b492484d6aa9ec3d90f9b1c550 100644 (file)
@@ -274,10 +274,13 @@ class UUID(object):
 def _find_mac(command, args, hw_identifiers, get_index):
     import os
     for dir in ['', '/sbin/', '/usr/sbin']:
+        executable = os.path.join(dir, command)
+        if not os.path.exists(executable):
+            continue
+
         try:
             # LC_ALL to get English output, 2>/dev/null to
             # prevent output on stderr
-            executable = os.path.join(dir, command)
             cmd = 'LC_ALL=C %s %s 2>/dev/null' % (executable, args)
             pipe = os.popen(cmd)
         except IOError: