[Title] Rollback "execute_with_log" on windows
authordonghee yang <donghee.yang@samsung.com>
Fri, 21 Sep 2012 17:05:27 +0000 (02:05 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Fri, 21 Sep 2012 17:05:27 +0000 (02:05 +0900)
src/common/utils.rb

index e74e27d98cccea2379dfc8821b8cfacf5dff63ce..70ee2ad160391b7142c093c24ada2603504f32ab 100644 (file)
@@ -198,18 +198,32 @@ class Utils
        # can decide whether wait or not
        def Utils.execute_shell_with_log(cmd, log_path, wait=true)
 
-               # call execute
-               cmd = "'#{File.dirname(__FILE__)}/execute_with_log' '#{cmd}' '#{log_path}'"
+               if get_os_category( HOST_OS ) != "windows" then
+                       # call execute
+                       cmd = "'#{File.dirname(__FILE__)}/execute_with_log' '#{cmd}' '#{log_path}'"
 
-               # generate command
-               cmd = generate_shell_command(cmd, nil)
+                       # generate command
+                       cmd = generate_shell_command(cmd, nil)
 
-               # print log
-               pipe = IO.popen("#{cmd} 2>&1")
-               if wait then
-                       return Process.waitpid2(pipe.pid)
+                       # print log
+                       pipe = IO.popen("#{cmd} 2>&1")
+                       if wait then
+                               return Process.waitpid2(pipe.pid)
+                       else
+                               return [pipe.pid,nil]
+                       end
                else
-                       return [pipe.pid,nil]
+                       # create logger
+                       log = Logger.new(log_path)
+
+                       IO.popen("#{cmd} 2>&1") { |io|
+                               io.each { |line|
+                               log.info line
+                               }
+                       }
+
+                       # return exit code
+                       return [nil, $?]
                end
        end