From: <jh...@us...> - 2009-10-29 20:41:14
|
Revision: 129 http://etch.svn.sourceforge.net/etch/?rev=129&view=rev Author: jheiss Date: 2009-10-29 20:41:05 +0000 (Thu, 29 Oct 2009) Log Message: ----------- Add support for files that depend on commands and vice-versa. Add featuring allowing the server to tell the client to retry certain commands on the next request. The "need sum" mechanism is used to do the same thing for files, but as commands have no original content saving mechanism we have to have an explicit feature for retries. The server needs this if it is unable to generate all of the prerequisites for the command, usually because the command depends on a file for which the server needs original content info. Modify generate_file and generate_commands methods to return a value indicating the status of the generation. Thus if either is called due to a dependency the caller knows whether it should proceed with its own generation, or tell the client to retry next time if one or more dependencies fail to generate due to a need for original content info. generate_file previously pulled this info out of the @generation_status hash, but it seems preferable to use a return value. In generate_file, if a dependency fails to generate don't explicitly go through the dependency tree and filter/need_orig each dependency. Each file where that is necessary has already handled itself, and it's fine if the client goes ahead and writes out other parts of the tree. Fix bug in generate_file, we need to return the (filtered) config for files which failed to generate due to a dependency failure, as the config may contain setup entries. Fix bug in xmlremove where it was calling the wrong REXML method if asked to remove an element from a document (as opposed to another element). The method call that was being used didn't generate an error, but also didn't do anything. This in turn meant that filter_xml_completely! was a no-op, which meant we were sending back unfiltered configs when we meant to send back just depend and setup entries. Modified Paths: -------------- trunk/server/lib/etch.rb Modified: trunk/server/lib/etch.rb =================================================================== --- trunk/server/lib/etch.rb 2009-10-29 20:40:41 UTC (rev 128) +++ trunk/server/lib/etch.rb 2009-10-29 20:41:05 UTC (rev 129) @@ -43,7 +43,7 @@ # if Logger didn't immediately blow up we'd probably end up with scrambled # logs as simultaneous connections tried to write at the same time. Or # maybe that would work, depending on how Ruby and the OS buffer writes to - # the file. + # the file? def initialize(logger, debug_logger) @logger = logger @dlogger = debug_logger @@ -178,7 +178,9 @@ @generation_status = {} @configs = {} @need_orig = {} - + @allcommands = {} + @retrycommands = {} + filelist.each do |file| @dlogger.debug "Generating #{file}" generate_file(file, request) @@ -188,8 +190,6 @@ # Generate configuration commands # - @allcommands = {} - commandnames = [] if request.empty? @dlogger.debug "Building complete configuration commands for request from #{@fqdn}" @@ -214,7 +214,8 @@ {:configs => @configs, :need_orig => @need_orig, - :allcommands => @allcommands} + :allcommands => @allcommands, + :retrycommands => @retrycommands} end # @@ -234,13 +235,16 @@ end parentshash.keys.sort end - + + # Returns the value of the generation_status variable, see comments in + # method for possible values. def generate_file(file, request) # Skip files we've already generated in response to <depend> # statements. if @already_generated[file] @dlogger.debug "Skipping already generated #{file}" - return + # Return the status of that previous generation + return @generation_status[file] end # Check for circular dependencies, otherwise we're vulnerable @@ -274,46 +278,43 @@ # As we go through the process of generating the file we'll end up with # four possible outcomes: # fatal error: raise an exception - # failure: we're missing needed data, generally the original file + # failure: we're missing needed data for this file or a dependency, + # generally the original file # success: we successfully processed a valid configuration # unknown: no valid configuration nor errors encountered, probably because - # filtering removed everything from the config.xml file + # filtering removed everything from the config.xml file. This + # should be considered a successful outcome, it indicates the + # caller/client provided us with all required data and our result + # is that no action needs to be taken. # We keep track of which of the failure, success or unknown states we end # up in via the generation_status variable. We initialize it to :unknown. # If we encounter either failure or success we set it to false or :success. catch :generate_done do # Generate any other files that this file depends on depends = [] + proceed = true Etch.xmleach(config_xml, '/config/depend') do |depend| @dlogger.debug "Generating dependency #{Etch.xmltext(depend)}" depends << Etch.xmltext(depend) - generate_file(Etch.xmltext(depend), request) + r = generate_file(Etch.xmltext(depend), request) + proceed = proceed && r end - # If any dependency failed to generate (due to a need for orig contents - # from the client) then we need to unroll the whole dependency tree and - # punt it back to the client - dependency_status = depends.all? { |depend| @generation_status[depend] } - if !dependency_status - depends.each do |depend| - # Make sure any configuration we're returning is just the basics - # needed to supply orig data - if @configs[depend] - filter_xml_completely!(@configs[depend], ['depend', 'setup']) - end - # And if we weren't already planning to request orig contents for this - # file then stick it into the orig request list so that the client - # knows it needs to ask for this file again next time. - if !@need_orig.has_key?(depend) - @need_orig[depend] = true - end - end - # Lastly make sure that this file gets sent back appropriately + # Also generate any commands that this file depends on + Etch.xmleach(config_xml, '/config/dependcommand') do |dependcommand| + @dlogger.debug "Generating command dependency #{Etch.xmltext(dependcommand)}" + r = generate_commands(Etch.xmltext(dependcommand), request) + proceed = proceed && r + end + if !proceed + @dlogger.debug "One or more dependencies of #{file} need data from client" + # Tell the client to request this file again @need_orig[file] = true + # Strip this file's config down to the bare necessities filter_xml_completely!(config_xml, ['depend', 'setup']) generation_status = false throw :generate_done end - + # Change into the corresponding directory so that the user can # refer to source files and scripts by their relative pathnames. Dir::chdir "#{@sourcebase}/#{file}" @@ -346,6 +347,7 @@ if request[:files] && request[:files][file] && request[:files][file][:orig] original_file = request[:files][file][:orig] else + @dlogger.debug "Need original contents of #{file} from client" @need_orig[file] = true # If there are setup commands defined for this file we need to # pass those back along with our request for the original file, @@ -777,8 +779,11 @@ end end end - - if generation_status && generation_status != :unknown && + + # In addition to successful configs return configs for files that need + # orig data (generation_status==false) because any setup commands might be + # needed to create the original file. + if generation_status != :unknown && Etch.xmlfindfirst(config_xml, '/config/*') # The client needs this attribute to know to which file # this chunk of XML refers @@ -789,8 +794,12 @@ @already_generated[file] = true @filestack.delete(file) @generation_status[file] = generation_status + + generation_status end + # Returns the value of the generation_status variable, see comments in + # method for possible values. def generate_commands(command, request) # Skip commands we've already generated in response to <depend> # statements. @@ -826,31 +835,67 @@ raise "Filtered commands.xml for #{command} fails validation" end - # Generate any other files that this file depends on - Etch.xmleach(commands_xml, '/commands/depend') do |depend| - @dlogger.debug "Generating command dependency #{Etch.xmltext(depend)}" - generate_commands(Etch.xmltext(depend), request) - end - - # Change into the corresponding directory so that the user can - # refer to source files and scripts by their relative pathnames. - Dir::chdir "#{@commandsbase}/#{command}" - - # Check that the resulting document is consistent after filtering - Etch.xmleach(commands_xml, '/commands/step') do |step| - guard_exec_elements = Etch.xmlarray(step, 'guard/exec') - if check_for_inconsistency(guard_exec_elements) - raise "Inconsistent guard 'exec' entries for #{command}" + generation_status = :unknown + # As we go through the process of generating the command we'll end up with + # four possible outcomes: + # fatal error: raise an exception + # failure: we're missing needed data for this command or a dependency, + # generally the original file for a file this command depends on + # success: we successfully processed a valid configuration + # unknown: no valid configuration nor errors encountered, probably because + # filtering removed everything from the commands.xml file. This + # should be considered a successful outcome, it indicates the + # caller/client provided us with all required data and our result + # is that no action needs to be taken. + # We keep track of which of the failure, success or unknown states we end + # up in via the generation_status variable. We initialize it to :unknown. + # If we encounter either failure or success we set it to false or :success. + catch :generate_done do + # Generate any other commands that this command depends on + proceed = true + Etch.xmleach(commands_xml, '/commands/depend') do |depend| + @dlogger.debug "Generating command dependency #{Etch.xmltext(depend)}" + r = generate_commands(Etch.xmltext(depend), request) + proceed = proceed && r end - command_exec_elements = Etch.xmlarray(step, 'command/exec') - if check_for_inconsistency(command_exec_elements) - raise "Inconsistent command 'exec' entries for #{command}" + # Also generate any files that this command depends on + Etch.xmleach(commands_xml, '/commands/dependfile') do |dependfile| + @dlogger.debug "Generating file dependency #{Etch.xmltext(dependfile)}" + r = generate_file(Etch.xmltext(dependfile), request) + proceed = proceed && r end + if !proceed + # Try again next time + @retrycommands[command] = true + generation_status = false + throw :generate_done + end + + # Change into the corresponding directory so that the user can + # refer to source files and scripts by their relative pathnames. + Dir::chdir "#{@commandsbase}/#{command}" + + # Check that the resulting document is consistent after filtering + Etch.xmleach(commands_xml, '/commands/step') do |step| + guard_exec_elements = Etch.xmlarray(step, 'guard/exec') + if check_for_inconsistency(guard_exec_elements) + raise "Inconsistent guard 'exec' entries for #{command}" + end + command_exec_elements = Etch.xmlarray(step, 'command/exec') + if check_for_inconsistency(command_exec_elements) + raise "Inconsistent command 'exec' entries for #{command}" + end + end + + # I'm not sure if we'd benefit from further checking the XML for + # validity. For now we declare success if we got this far. + generation_status = :success end # If filtering didn't remove all the content then add this to the list of # commands to be returned to the client. - if Etch.xmlfindfirst(commands_xml, '/commands/*') + if generation_status && generation_status != :unknown && + Etch.xmlfindfirst(commands_xml, '/commands/*') # Include the commands directory name to aid troubleshooting on the # client side. Etch.xmlattradd(Etch.xmlroot(commands_xml), 'commandname', command) @@ -859,6 +904,9 @@ @already_generated[command] = true @filestack.delete(command) + @generation_status[command] = generation_status + + generation_status end ALWAYS_KEEP = ['depend', 'setup', 'pre', 'test_before_post', 'post', 'test'] @@ -1198,7 +1246,11 @@ when :libxml element.remove! when :rexml - xmldoc.elements.delete(element) + if xmldoc.node_type == :document + xmldoc.root.elements.delete(element) + else + xmldoc.elements.delete(element) + end else raise "Unknown @xmllib #{@xmllib}" end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2009-11-06 19:54:30
|
Revision: 140 http://etch.svn.sourceforge.net/etch/?rev=140&view=rev Author: jheiss Date: 2009-11-06 19:54:22 +0000 (Fri, 06 Nov 2009) Log Message: ----------- Wrap exceptions from templates with a message indicating the template and associated file names to help the user figure out where the error occurred. Already doing this for scripts, guess I forgot to do the same for templates. Modified Paths: -------------- trunk/server/lib/etch.rb Modified: trunk/server/lib/etch.rb =================================================================== --- trunk/server/lib/etch.rb 2009-11-06 01:04:05 UTC (rev 139) +++ trunk/server/lib/etch.rb 2009-11-06 19:54:22 UTC (rev 140) @@ -1339,7 +1339,13 @@ # The binding arg ties the template's namespace to this point in the # code, thus ensuring that all of the variables above (@file, etc.) # are visible to the template code. - erb.result(binding) + begin + erb.result(binding) + rescue Exception => e + # Help the user figure out where the exception occurred, otherwise they + # just get told it happened here, which isn't very helpful. + raise e.exception("Exception while processing template #{template} for file #{@file}:\n" + e.message) + end end # This method runs a etch script (as specified via a <script> entry This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2010-03-31 17:00:23
|
Revision: 204 http://etch.svn.sourceforge.net/etch/?rev=204&view=rev Author: jheiss Date: 2010-03-31 17:00:15 +0000 (Wed, 31 Mar 2010) Log Message: ----------- When we catch and re-raise exceptions (in order to add additional info to the exception message) from user code (processing user XML, scripts, and templates) set the re-raised exception's backtrace to the original backtrace so that the backtrace info is not lost. Added method self.wrap_exception to handle this. Modified Paths: -------------- trunk/server/lib/etch.rb Modified: trunk/server/lib/etch.rb =================================================================== --- trunk/server/lib/etch.rb 2010-03-31 01:29:46 UTC (rev 203) +++ trunk/server/lib/etch.rb 2010-03-31 17:00:15 UTC (rev 204) @@ -266,7 +266,7 @@ begin configfilter!(Etch.xmlroot(config_xml)) rescue Exception => e - raise e.exception("Error filtering config.xml for #{file}:\n" + e.message) + raise Etch.wrap_exception(e, "Error filtering config.xml for #{file}:\n" + e.message) end # Validate the filtered file against config.dtd @@ -842,7 +842,7 @@ begin configfilter!(Etch.xmlroot(commands_xml)) rescue Exception => e - raise e.exception("Error filtering commands.xml for #{command}:\n" + e.message) + raise Etch.wrap_exception(e, "Error filtering commands.xml for #{command}:\n" + e.message) end # Validate the filtered file against commands.dtd @@ -911,12 +911,12 @@ raise "Inconsistent command 'exec' entries for #{command}: " + command_exec_elements.collect {|elem| Etch.xmltext(elem)}.join(',') end - # If filtering has removed both the guard and command elements - # we can remove this step. + # If filtering has removed both the guard and command elements + # we can remove this step. if guard_exec_elements.empty? && command_exec_elements.empty? remove << step - # If filtering has removed the guard but not the command or vice - # versa that's an error. + # If filtering has removed the guard but not the command or vice + # versa that's an error. elsif guard_exec_elements.empty? raise "Filtering removed guard, but left command: " + Etch.xmltext(command_exec_elements.first) @@ -1328,6 +1328,16 @@ raise "Unknown @xmllib #{@xmllib}" end end + + # Used where we wish to capture an exception and modify the message. This + # method returns a new exception with desired message but with the backtrace + # from the original exception so that the backtrace info is not lost. This + # is necessary because Exception lacks a set_message method. + def self.wrap_exception(e, message) + eprime = e.exception(message) + eprime.set_backtrace(e.backtrace) + eprime + end end class EtchExternalSource @@ -1363,7 +1373,7 @@ rescue Exception => e # Help the user figure out where the exception occurred, otherwise they # just get told it happened here, which isn't very helpful. - raise e.exception("Exception while processing template #{template} for file #{@file}:\n" + e.message) + raise Etch.wrap_exception(e, "Exception while processing template #{template} for file #{@file}:\n" + e.message) end end @@ -1382,7 +1392,7 @@ else # Help the user figure out where the exception occurred, otherwise they # just get told it happened here in eval, which isn't very helpful. - raise e.exception("Exception while processing script #{script} for file #{@file}:\n" + e.message) + raise Etch.wrap_exception(e, "Exception while processing script #{script} for file #{@file}:\n" + e.message) end end @contents This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2011-04-12 06:20:15
|
Revision: 269 http://etch.svn.sourceforge.net/etch/?rev=269&view=rev Author: jheiss Date: 2011-04-12 06:20:09 +0000 (Tue, 12 Apr 2011) Log Message: ----------- When reading in the node group hierarchy use the xmlattrvalue method rather than directly talking to the underlying XML library. The code to do so was not compatible with nokogiri. Modified Paths: -------------- trunk/server/lib/etch.rb Modified: trunk/server/lib/etch.rb =================================================================== --- trunk/server/lib/etch.rb 2011-04-12 06:08:33 UTC (rev 268) +++ trunk/server/lib/etch.rb 2011-04-12 06:20:09 UTC (rev 269) @@ -135,7 +135,7 @@ Etch.xmleach(@nodegroups_xml, '/nodegroups/nodegroup') do |parent| Etch.xmleach(parent, 'child') do |child| @group_hierarchy[Etch.xmltext(child)] = [] if !@group_hierarchy[Etch.xmltext(child)] - @group_hierarchy[Etch.xmltext(child)] << parent.attributes['name'] + @group_hierarchy[Etch.xmltext(child)] << Etch.xmlattrvalue(parent, 'name') end end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2011-05-04 22:01:51
|
Revision: 280 http://etch.svn.sourceforge.net/etch/?rev=280&view=rev Author: jheiss Date: 2011-05-04 22:01:45 +0000 (Wed, 04 May 2011) Log Message: ----------- Load 3rd party libraries inside Silently since several of them emit warnings under ruby 1.9 Modified Paths: -------------- trunk/server/lib/etch.rb Modified: trunk/server/lib/etch.rb =================================================================== --- trunk/server/lib/etch.rb 2011-05-04 21:57:20 UTC (rev 279) +++ trunk/server/lib/etch.rb 2011-05-04 22:01:45 UTC (rev 280) @@ -1,11 +1,17 @@ -require 'find' # Find.find -require 'pathname' # absolute? -require 'digest/sha1' # hexdigest -require 'base64' # decode64, encode64 -require 'fileutils' # mkdir_p -require 'erb' +# Exclude standard libraries and gems from the warnings induced by +# running ruby with the -w flag. Several of these have warnings under +# ruby 1.9 and there's nothing we can do to fix that. +require 'silently' +Silently.silently do + require 'find' # Find.find + require 'pathname' # absolute? + require 'digest/sha1' # hexdigest + require 'base64' # decode64, encode64 + require 'fileutils' # mkdir_p + require 'erb' + require 'logger' +end require 'versiontype' # Version -require 'logger' class Etch def self.xmllib @@ -19,25 +25,27 @@ # By default we try to use libxml, falling back to rexml if it is not # available. The xmllib environment variable can be used to force one library # or the other, mostly for testing purposes. -begin - if !ENV['xmllib'] || ENV['xmllib'] == 'libxml' - require 'rubygems' # libxml is a gem - require 'libxml' - Etch.xmllib = :libxml - elsif ENV['xmllib'] == 'nokogiri' - require 'rubygems' # nokogiri is a gem - require 'nokogiri' - Etch.xmllib = :nokogiri - else - raise LoadError +Silently.silently do + begin + if !ENV['xmllib'] || ENV['xmllib'] == 'libxml' + require 'rubygems' # libxml is a gem + require 'libxml' + Etch.xmllib = :libxml + elsif ENV['xmllib'] == 'nokogiri' + require 'rubygems' # nokogiri is a gem + require 'nokogiri' + Etch.xmllib = :nokogiri + else + raise LoadError + end + rescue LoadError + if !ENV['xmllib'] || ENV['xmllib'] == 'rexml' + require 'rexml/document' + Etch.xmllib = :rexml + else + raise + end end -rescue LoadError - if !ENV['xmllib'] || ENV['xmllib'] == 'rexml' - require 'rexml/document' - Etch.xmllib = :rexml - else - raise - end end class Etch This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2011-06-01 16:39:45
|
Revision: 292 http://etch.svn.sourceforge.net/etch/?rev=292&view=rev Author: jheiss Date: 2011-06-01 16:39:39 +0000 (Wed, 01 Jun 2011) Log Message: ----------- Make nokogiri the default XML library instead of libxml Modified Paths: -------------- trunk/server/lib/etch.rb Modified: trunk/server/lib/etch.rb =================================================================== --- trunk/server/lib/etch.rb 2011-06-01 16:39:16 UTC (rev 291) +++ trunk/server/lib/etch.rb 2011-06-01 16:39:39 UTC (rev 292) @@ -27,14 +27,14 @@ # or the other, mostly for testing purposes. Silently.silently do begin - if !ENV['xmllib'] || ENV['xmllib'] == 'libxml' + if !ENV['xmllib'] || ENV['xmllib'] == 'nokogiri' + require 'rubygems' # nokogiri is a gem + require 'nokogiri' + Etch.xmllib = :nokogiri + elsif ENV['xmllib'] == 'libxml' require 'rubygems' # libxml is a gem require 'libxml' Etch.xmllib = :libxml - elsif ENV['xmllib'] == 'nokogiri' - require 'rubygems' # nokogiri is a gem - require 'nokogiri' - Etch.xmllib = :nokogiri else raise LoadError end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2011-07-09 00:26:35
|
Revision: 297 http://etch.svn.sourceforge.net/etch/?rev=297&view=rev Author: jheiss Date: 2011-07-09 00:26:29 +0000 (Sat, 09 Jul 2011) Log Message: ----------- Use REXML's deep_clone rather than dup or clone in xmlcopyelem. I originaly used dup, but switched to clone in commit 267. dup made a copy that wasn't really a copy, xmlsettext would change the original as well. clone fixed that problem, but it turns out it didn't copy the contents of the element. So <foo>text</foo> became <foo/>. deep_clone fixes those issues. (And the unit tests now test for both of those issues.) Modified Paths: -------------- trunk/server/lib/etch.rb Modified: trunk/server/lib/etch.rb =================================================================== --- trunk/server/lib/etch.rb 2011-07-09 00:19:36 UTC (rev 296) +++ trunk/server/lib/etch.rb 2011-07-09 00:26:29 UTC (rev 297) @@ -1372,7 +1372,7 @@ when :nokogiri destelem << elem.dup when :rexml - destelem.add_element(elem.clone) + destelem.add_element(elem.deep_clone) else raise "Unknown XML library #{Etch.xmllib}" end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2011-07-09 00:36:55
|
Revision: 298 http://etch.svn.sourceforge.net/etch/?rev=298&view=rev Author: jheiss Date: 2011-07-09 00:36:49 +0000 (Sat, 09 Jul 2011) Log Message: ----------- Change a few instances of Dir::chdir to Dir.chdir and similar, both work but the later is more common. Modified Paths: -------------- trunk/server/lib/etch.rb Modified: trunk/server/lib/etch.rb =================================================================== --- trunk/server/lib/etch.rb 2011-07-09 00:26:29 UTC (rev 297) +++ trunk/server/lib/etch.rb 2011-07-09 00:36:49 UTC (rev 298) @@ -375,7 +375,7 @@ # Change into the corresponding directory so that the user can # refer to source files and scripts by their relative pathnames. - Dir::chdir "#{@sourcebase}/#{file}" + Dir.chdir "#{@sourcebase}/#{file}" # See what type of action the user has requested @@ -426,7 +426,7 @@ # Just slurp the file in plain_file = Etch.xmltext(plain_elements.first) - newcontents = IO::read(plain_file) + newcontents = IO.read(plain_file) elsif Etch.xmlfindfirst(config_xml, '/config/file/source/template') template_elements = Etch.xmlarray(config_xml, '/config/file/source/template') if check_for_inconsistency(template_elements) @@ -925,7 +925,7 @@ # Change into the corresponding directory so that the user can # refer to source files and scripts by their relative pathnames. - Dir::chdir "#{@commandsbase}/#{command}" + Dir.chdir "#{@commandsbase}/#{command}" # Check that the resulting document is consistent after filtering remove = [] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2012-03-02 16:13:57
|
Revision: 305 http://etch.svn.sourceforge.net/etch/?rev=305&view=rev Author: jheiss Date: 2012-03-02 16:13:50 +0000 (Fri, 02 Mar 2012) Log Message: ----------- Update comment about which xml library is used by default Modified Paths: -------------- trunk/server/lib/etch.rb Modified: trunk/server/lib/etch.rb =================================================================== --- trunk/server/lib/etch.rb 2012-03-02 16:13:17 UTC (rev 304) +++ trunk/server/lib/etch.rb 2012-03-02 16:13:50 UTC (rev 305) @@ -22,9 +22,9 @@ end end -# By default we try to use libxml, falling back to rexml if it is not -# available. The xmllib environment variable can be used to force one library -# or the other, mostly for testing purposes. +# By default we try to use nokogiri, falling back to rexml if it is not +# available. The xmllib environment variable can be used to force a specific +# library, mostly for testing purposes. Silently.silently do begin if !ENV['xmllib'] || ENV['xmllib'] == 'nokogiri' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2012-04-24 17:01:18
|
Revision: 317 http://etch.svn.sourceforge.net/etch/?rev=317&view=rev Author: jheiss Date: 2012-04-24 17:01:12 +0000 (Tue, 24 Apr 2012) Log Message: ----------- chdir back to / after processing individual files or commands. We chdir into the directory for the individual file/command before processing it so that the user can refer to other files in the same directory using relative paths. In practice it hasn't caused any problems to leave the server chdir'd into that directory until it processes the next file, but it does generate sporadic errors from the test suite when the directory disappears as the repository is updated. So to be on the safe and robust side we now chdir back to / after processing an individual file or command. Modified Paths: -------------- trunk/server/lib/etch.rb Modified: trunk/server/lib/etch.rb =================================================================== --- trunk/server/lib/etch.rb 2012-04-24 16:58:35 UTC (rev 316) +++ trunk/server/lib/etch.rb 2012-04-24 17:01:12 UTC (rev 317) @@ -822,6 +822,10 @@ end end + # Earlier we chdir'd into the file's directory in the repository. It + # seems best not to leave this process with that as the cwd. + Dir.chdir('/') + # In addition to successful configs return configs for files that need # orig data (generation_status==false) because any setup commands might be # needed to create the original file. @@ -961,6 +965,10 @@ generation_status = :success end + # Earlier we chdir'd into the command's directory in the repository. It + # seems best not to leave this process with that as the cwd. + Dir.chdir('/') + # If filtering didn't remove all the content then add this to the list of # commands to be returned to the client. if generation_status && generation_status != :unknown && This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jh...@us...> - 2012-04-24 20:00:03
|
Revision: 321 http://etch.svn.sourceforge.net/etch/?rev=321&view=rev Author: jheiss Date: 2012-04-24 19:59:57 +0000 (Tue, 24 Apr 2012) Log Message: ----------- Wrap the config.xml load step with wrap_exception so that the user gets a useful error message. Modified Paths: -------------- trunk/server/lib/etch.rb Modified: trunk/server/lib/etch.rb =================================================================== --- trunk/server/lib/etch.rb 2012-04-24 19:52:53 UTC (rev 320) +++ trunk/server/lib/etch.rb 2012-04-24 19:59:57 UTC (rev 321) @@ -285,7 +285,11 @@ end # Load the config.xml file - config_xml = Etch.xmlload(config_xml_file) + begin + config_xml = Etch.xmlload(config_xml_file) + rescue Exception => e + raise Etch.wrap_exception(e, "Error loading config.xml for #{file}:\n" + e.message) + end # Filter the config.xml file by looking for attributes begin This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |