stdoutdata can be None object
[bootmanager.git] / source / utils.py
index f57a0a3..4f96fd2 100644 (file)
@@ -134,7 +134,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 +148,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()