Oh yeah definitely but because the test() command (in my implementation) doesn't make any system/application changes I leave it as is.
On Monday, 20 October 2014 18:56:57 UTC+11, Lee Hambley wrote: > > You won't be able to pass any test() command by just printing, since test > relies on the answer from the upstream server to determine which way the > Ruby code should branch. > > Lee Hambley > -- > http://lee.hambley.name/ > +49 (0) 170 298 5667 > > On 20 October 2014 08:55, Haani Niyaz <haani...@gmail.com <javascript:>> > wrote: > >> I was also curious to know if there was a better way to do this? cheers. >> >> >> On Monday, 20 October 2014 17:54:47 UTC+11, Haani Niyaz wrote: >>> >>> Hi There, >>> >>> I am attempted to have Capistrano tasks only display the commands >>> instead of executing them. I did this by basically using a function which >>> determines if the command needs to be executed or printed based on a >>> 'debug' flag passed as an argument which would be accessed as a environment >>> variable, however I encountered some exceptions: >>> >>> What I've done: >>> >>> def execute_as cmd >>> >>> if $debug.eql? 'true' >>> puts cmd >>> else >>> execute "#{cmd}" >>> end >>> >>> >>> The above works fine for all except for the following scenario: >>> >>> # fails for any test command >>> if test(" [ ! -d /usr/backup ] ") >>> puts "+ Creating backup point /usr/backup.." >>> execute_as "sudo mkdir /usr/backup" >>> puts "#{$checkmark} Created /usr/backup" >>> end >>> >>> >>> The exception below is: >>> 1. Only generated when it encounters the first test command. >>> 2. Does not terminate. Prints all command successfully until the end. >>> >>> >>> DEBUG[ba34641c] Command: [ ! -d /usr/backup ] >>> Exception `Net::SSH::Exception' at /opt/ruby/ruby-2.0.0-p451/usr/ >>> lib64/ruby/gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/transport/algorithms.rb:329 >>> >>> - could not settle on language_client algorithm >>> Exception `Net::SSH::Exception' at /opt/ruby/ruby-2.0.0-p451/usr/ >>> lib64/ruby/gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/transport/algorithms.rb:329 >>> >>> - could not settle on language_server algorithm >>> Exception `Net::SSH::Authentication::DisallowedMethod' at /opt/ruby/ruby >>> -2.0.0-p451/usr/lib64/ruby/gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/ >>> authentication/methods/none.rb:23 - Net::SSH::Authentication::Disa >>> llowedMethod >>> Exception `TypeError' at /opt/ruby/ruby-2.0.0-p451/usr/ >>> lib64/ruby/gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/ >>> authentication/agent/socket.rb:65 - no implicit conversion of nil into >>> String >>> Exception `Net::SSH::Authentication::AgentNotAvailable' at >>> /opt/ruby/ruby-2.0.0-p451/usr/lib64/ruby/gems/2.0.0/gems/ >>> net-ssh-2.9.1/lib/net/ssh/authentication/agent/socket.rb:68 - no >>> implicit conversion of nil into String >>> >>> >>> I can SSH into the remote server successfully and if the debug option is >>> off, no exceptions are generated. >>> >>> A closer look led me to change the environment variable name (instead of >>> using 'debug') which solved the problem. >>> >>> I was hoping someone could explain this behavior? >>> Thanks. >>> >>> >>> Versions: >>> >>> - Ruby 1.8.7 >>> - Capistrano 3 >>> >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Capistrano" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to capistrano+...@googlegroups.com <javascript:>. >> To view this discussion on the web, visit >> https://groups.google.com/d/msgid/capistrano/0a9b03b2-6e54-477d-9599-1d8163afb43e%40googlegroups.com >> >> <https://groups.google.com/d/msgid/capistrano/0a9b03b2-6e54-477d-9599-1d8163afb43e%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Capistrano" group. To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+unsubscr...@googlegroups.com. To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/b467f973-9b9d-45a9-ba90-f0779b1256f1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.