cosmetic
[bootmanager.git] / source / utils.py
index 696f3f3..02a30cd 100644 (file)
@@ -1,8 +1,5 @@
 #!/usr/bin/python
 #
-# $Id$
-# $URL$
-#
 # Copyright (c) 2003 Intel Corporation
 # All rights reserved.
 #
@@ -134,7 +131,10 @@ def sysexec( cmd, log= None, fsck = False ):
         print ("sysexec >>> %s" % cmd)
 
     try:
-        prog = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        if cmd.__contains__(">"):
+            prog = subprocess.Popen(cmd, shell=True)
+        else:
+            prog = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     except OSError:
         raise BootManagerException, \
               "Unable to create instance of subprocess.Popen " \
@@ -145,7 +145,8 @@ def sysexec( cmd, log= None, fsck = False ):
         raise BootManagerException, "Interrupted by user"
 
     if log is not None:
-        log.write(stdoutdata)
+        if stdoutdata is not None:
+            log.write(stdoutdata)
 
     returncode = prog.wait()
 
@@ -159,7 +160,7 @@ def sysexec( cmd, log= None, fsck = False ):
        #      16   - Usage or syntax error
        #      32   - Fsck canceled by user request
        #      128  - Shared library error
-       if returncode != 0 or returncode != 1:
+       if returncode != 0 and returncode != 1:
             raise BootManagerException, "Running %s failed (rc=%d)" % (cmd,returncode)
     else:
         if returncode != 0: