[Title] Fixed log system to be separated from communication
authordibs <dibs@samsung.com>
Thu, 28 Mar 2013 09:53:37 +0000 (18:53 +0900)
committerdibs <dibs@samsung.com>
Thu, 28 Mar 2013 09:53:37 +0000 (18:53 +0900)
build-cli
dibs-web/app/controllers/projects_controller.rb
dibs-web/app/controllers/utils.rb
dibs-web/public/javascripts/build.js
dibs-web/public/javascripts/projects.js

index 6b66de9b622051123493c5ea19331c974e1a8937..746ae950792896f4029785f3cb08d40a179260e0 100755 (executable)
--- a/build-cli
+++ b/build-cli
@@ -336,16 +336,15 @@ begin
 
                addr = Utils.parse_server_addr(option[:domain])
                if addr.nil? then
-                       log.puts "Server address is incorrect. (#{option[:domain]})"
-                       log.puts "Tune as following format."
-                       log.puts " <ip>:<port>"
+                       puts "Server address is incorrect. (#{option[:domain]})"
+                       puts "Tune as following format."
+                       puts " <ip>:<port>"
                        exit 1
                end
 
                client = BuildCommClient.create( addr[0], addr[1], nil, 0 )
                if client.nil? then
-                       log.puts "Connection to server failed!"
-                       return nil
+                       raise RuntimeError, "The output file is already exist."
                end
 
                client.send "LOG|#{option[:job].strip}"
@@ -365,8 +364,12 @@ begin
                end
 
                if not result then
-                       log.puts "ERROR: Communication failed! #{client.get_error_msg()}"
+                       puts "ERROR: Communication failed! #{client.get_error_msg()}"
                        client.terminate
+                       log.close
+                       if not output.nil? then
+                               FileUtils.rm output
+                       end
                        exit 1
                else
                        client.terminate
index 21c5cc18e853988ea91d0d737757d758f08cdd61..8aafe4e855d2ba67c7aafd46045d19adf65906c1 100644 (file)
@@ -69,13 +69,15 @@ class ProjectsController < ApplicationController
        if (project_list.length > 1) or (not (project_list[0].nil? or project_list[0].empty?))
                # execute build command
                begin
-                       Utils.sbi_build_command(dist_name, project_list, os_list, password_list, get_user_email)
+                       result, job_id, msg = Utils.sbi_build_command(dist_name, project_list, os_list, password_list, get_user_email)
+                       if result then
+                               render :json => { :result => "SUCCESS", :job_id => job_id }
+                       else
+                               render :json => { :result => "ERROR", :message => msg }
+                       end
                rescue => e
                        render :text => e.message, :status => 406
-                       return
                end
-    
-               render :json => { :success => "OK!" }
        else
                render :text => "Can't build project", :status => 406
        end
index 7c928bf72e8cd96d4bb24dfbcaa7071a57a4e3fd..d6b9ba413b679a69116840f5169a3b6da1e3265b 100644 (file)
@@ -32,6 +32,7 @@ DIBS_PATH = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))
 
 class Utils < ApplicationController
   def Utils.sbi_build_command(distribution, project_list, os_list, password_list, email)
+       job_id = nil
        dibs_config = Server_config.find(:first, :conditions => ["property = \"port\""])
        if dibs_config.nil?
                raise RuntimeError, "Can't find server port information"
@@ -55,7 +56,13 @@ class Utils < ApplicationController
 puts "Build command"
 puts "[[[#{cmd}]]]"
 
-       return execute_shell_return(cmd)
+       result, msg = execute_shell_return(cmd)
+       msg.each { |line|
+               if line =~ /Info: Added new job "([0-9][0-9]*)" for.*/ then 
+                       job_id = $1 
+               end
+       }
+       return result, job_id, msg
   end
 
   def Utils.sbi_register_command(distribution, file_path, password, email)
@@ -142,14 +149,21 @@ puts "[[[#{cmd}]]]"
   end
 
   def Utils.execute_shell_return(cmd)
+       result = false
     result_lines = []
-    ret = false
   
     # get result
-    #IO.popen("#{cmd}")
-    system "#{cmd}"
+       IO.popen("#{cmd} 2>&1") do |io|
+               io.each do |line|
+                       result_lines.push line
+               end
+       end
+
+       if $? == 0 then
+               result = true
+       end
 
-       return true
+       return result, result_lines
   end
 
        # set static variable in WORKING_DIR, HOME
index 781f9f6e34af3ec0fab7e640681f57715ac3ac4c..8bad6e516f3a6b93f83a2892918274313d757cd1 100644 (file)
@@ -320,8 +320,18 @@ function buildBuildProject() {
                }
        }
        
-       buildProject(buildProjectList, function () {
-               $.mobile.changePage("#jobs"); 
+       buildProject(buildProjectList, function (json) {
+               if(json.result != "SUCCESS") {
+                       if(json.error != "") {
+                               alert(json.message);
+                       }
+                       else {
+                               alert("Build request fail!");
+                       }
+               }
+               else {
+                       $.mobile.changePage("#jobs"); 
+               }
        });
 }
 
index fdfb8cb18f570080a70dd8d43f09f35e36596fce..e982f67efd6af783b464336ac4f07fba4f878c3e 100644 (file)
@@ -88,6 +88,7 @@ function projectsQueryProjectListType(queryType) {
 
                $('.projects-project-list-collapsible').collapsible();
                $('.projects-project-list-listview').listview();
+               
        });
 }
 
@@ -114,12 +115,6 @@ function projectsAppendProjectList( project, projectList ) {
        h2.innerHTML = '<span class="alignleft">'+name+'</span><span class="alignright">'+type+'</span>';
        div.appendChild(h2);
 
-       var testDiv = document.createElement('div');
-       //testDiv.innerHTML = '<label><input type="checkbox" name="checkbox-mini-0" class="custom" data-mini="true" />Build</label>';
-       testDiv.innerHTML = '<div data-role="fieldcontain"><fieldset data-role="controlgroup" data-type="horizontal"><legend>Font styling:</legend><input type="checkbox" name="checkbox-6" id="checkbox-6" class="custom" /><label for="checkbox-6">b</label></fieldset></div>';
-       h2.appendChild(testDiv);
-       $('#checkbox-6').checkboxradio();
-
        var infoLine = document.createElement('p');
        infoLine.setAttribute('style', 'font-size: 12px');
        infoLine.innerHTML = "Maintainer : "+maintainer+"<br><br>";