Author: tchemit Date: 2015-12-15 08:45:55 +0100 (Tue, 15 Dec 2015) New Revision: 132 Url: http://forge.codelutin.com/projects/adminsys/repository/revisions/132 Log: Mise ?\195?\160 jour des scripts utilis?\195?\169s lors de la cr?\195?\169ation d'un projet Modified: scripts/redmine-tools/project-list.rb scripts/redmine-tools/project-scm.rb scripts/redmine-tools/project-site.rb scripts/redmine-tools/project-technical-site.rb Modified: scripts/redmine-tools/project-list.rb =================================================================== --- scripts/redmine-tools/project-list.rb 2015-12-15 07:44:54 UTC (rev 131) +++ scripts/redmine-tools/project-list.rb 2015-12-15 07:45:55 UTC (rev 132) @@ -41,9 +41,10 @@ print "run /opt/redmine-tools/project-list.rb #{ARGV}\n" #tchemit - fix verbose deprecated warning about iconv (since it used in cron, don't want to header about it) -oldverb = $VERBOSE; $VERBOSE = nil -require 'iconv' -$VERBOSE = oldverb +# poussin 20150708 load iconv file faild (doesn't exist) try without it +##oldverb = $VERBOSE; $VERBOSE = nil +##require 'iconv' +##$VERBOSE = oldverb require 'getoptlong' #require 'rdoc/usage' @@ -115,6 +116,8 @@ #class Project < ActiveRecord::Base self.headers["User-agent"] = "Redmine repository manager/#{Version}" + # /sys only return xml :(. remove /sys return json but parse must be change: see https://www.mail-archive.com/rubyonrails-talk@googlegroups.com/msg126406.htm... + self.format = :xml end log("querying Redmine for projects...", :level => 1); @@ -197,4 +200,3 @@ end end - Modified: scripts/redmine-tools/project-scm.rb =================================================================== --- scripts/redmine-tools/project-scm.rb 2015-12-15 07:44:54 UTC (rev 131) +++ scripts/redmine-tools/project-scm.rb 2015-12-15 07:45:55 UTC (rev 132) @@ -35,13 +35,22 @@ # == References # # You can find more information on the redmine's wiki : http://www.redmine.org/wiki/redmine/HowTos +# +# == ChangeLog +# +# 20150708 poussin@codelutin.com +# - comment unused require iconv +# - remove /sys in URL to return json and not XML +# - add ProjectCollection to parse correctly redmine json +# print "run /opt/redmine-tools/project-scm.rb #{ARGV}\n" #tchemit - fix verbose deprecated warning about iconv (since it used in cron, don't want to header about it) -oldverb = $VERBOSE; $VERBOSE = nil -require 'iconv' -$VERBOSE = oldverb +# poussin 20150708 load iconv file faild (doesn't exist) try without it +##oldverb = $VERBOSE; $VERBOSE = nil +##require 'iconv' +##$VERBOSE = oldverb require 'getoptlong' #require 'rdoc/usage' @@ -110,21 +119,30 @@ log("This script requires activeresource.\nRun 'gem install activeresource' to install it.", :exit => true) end +$redmine_host.gsub!(/^/, "http://") unless $redmine_host.match("^https?://") +$redmine_host.gsub!(/\/$/, '') + +class ProjectCollection < ActiveResource::Collection + def initialize(parsed = {}) + @elements = parsed['projects'] + end +end + class Project < ActiveResource::Base self.headers["User-agent"] = "Redmine repository manager/#{Version}" + self.site = "#{$redmine_host}/"; + self.collection_parser = ProjectCollection; end log("querying Redmine for projects...", :level => 1); -$redmine_host.gsub!(/^/, "http://") unless $redmine_host.match("^https?://") -$redmine_host.gsub!(/\/$/, '') -Project.site = "#{$redmine_host}/sys"; - begin # Get all active projects that have the Repository module enabled projects = Project.find(:all, :params => {:key => $api_key}) rescue => e + log("uncaught #{e} exception while handling connection: #{e.message}", :level => 1); + log("Stack trace: #{e.backtrace}", :level => 1); log("Unable to connect to #{Project.site}: #{e}", :exit => true) end Modified: scripts/redmine-tools/project-site.rb =================================================================== --- scripts/redmine-tools/project-site.rb 2015-12-15 07:44:54 UTC (rev 131) +++ scripts/redmine-tools/project-site.rb 2015-12-15 07:45:55 UTC (rev 132) @@ -34,9 +34,10 @@ print "run /opt/redmine-tools/project-site.rb #{ARGV}\n" #tchemit - fix verbose deprecated warning about iconv (since it used in cron, don't want to header about it) -oldverb = $VERBOSE; $VERBOSE = nil -require 'iconv' -$VERBOSE = oldverb +# poussin 20150708 load iconv file faild (doesn't exist) try without it +##oldverb = $VERBOSE; $VERBOSE = nil +##require 'iconv' +##$VERBOSE = oldverb require 'getoptlong' #require 'rdoc/usage' @@ -99,6 +100,8 @@ #class Project < ActiveRecord::Base self.headers["User-agent"] = "Redmine repository manager/#{Version}" + # /sys only return xml :(. remove /sys return json but parse must be change: see https://www.mail-archive.com/rubyonrails-talk@googlegroups.com/msg126406.htm... + self.format = :xml end log("querying Redmine for projects...", :level => 1); Modified: scripts/redmine-tools/project-technical-site.rb =================================================================== --- scripts/redmine-tools/project-technical-site.rb 2015-12-15 07:44:54 UTC (rev 131) +++ scripts/redmine-tools/project-technical-site.rb 2015-12-15 07:45:55 UTC (rev 132) @@ -30,9 +30,10 @@ print "run /opt/redmine-tools/project-technical-site.rb #{ARGV}\n" #tchemit - fix verbose deprecated warning about iconv (since it used in cron, don't want to header about it) -oldverb = $VERBOSE; $VERBOSE = nil -require 'iconv' -$VERBOSE = oldverb +# poussin 20150708 load iconv file faild (doesn't exist) try without it +##oldverb = $VERBOSE; $VERBOSE = nil +##require 'iconv' +##$VERBOSE = oldverb require 'getoptlong' #require 'rdoc/usage' @@ -95,6 +96,8 @@ #class Project < ActiveRecord::Base self.headers["User-agent"] = "Redmine repository manager/#{Version}" + # /sys only return xml :(. remove /sys return json but parse must be change: see https://www.mail-archive.com/rubyonrails-talk@googlegroups.com/msg126406.htm... + self.format = :xml end log("querying Redmine for projects...", :level => 1);
participants (1)
-
tchemit@users.forge.codelutin.com