From 29fc7f3c14b36770caad64cb82ec9177384ab61a Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 20 Aug 2014 19:04:47 -0400 Subject: v5 v6: start making use of --no-stop command --- lib/sisu/v5/ao_images.rb | 11 +++++++++++ lib/sisu/v5/db_create.rb | 30 +++++++++++++++++++++++++++++- lib/sisu/v5/db_indexes.rb | 20 +++++++++++++++++--- lib/sisu/v5/dbi.rb | 25 +++++++++++++++++++++---- lib/sisu/v5/se_db.rb | 7 ++++++- lib/sisu/v5/texpdf.rb | 30 +++++++++++++++++++++++++++--- lib/sisu/v6/ao_images.rb | 11 +++++++++++ lib/sisu/v6/db_create.rb | 30 +++++++++++++++++++++++++++++- lib/sisu/v6/db_indexes.rb | 20 +++++++++++++++++--- lib/sisu/v6/dbi.rb | 25 +++++++++++++++++++++---- lib/sisu/v6/se_db.rb | 7 ++++++- lib/sisu/v6/texpdf.rb | 30 +++++++++++++++++++++++++++--- 12 files changed, 222 insertions(+), 24 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/ao_images.rb b/lib/sisu/v5/ao_images.rb index dce92fc5..dd33833d 100644 --- a/lib/sisu/v5/ao_images.rb +++ b/lib/sisu/v5/ao_images.rb @@ -134,6 +134,17 @@ module SiSU_AO_Images end img_col,img_row=/(\d+)x(\d+)/m.match(imgsys)[1,2] img_col,img_row=img_col.to_i,img_row.to_i + else + errmsg='imagemagick or graphicksmagick are required to process images' + if @md.opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, proceeding (as requested) without image processing") + break + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, STOPPING") + exit + end end end row=((img && defined? img.rows) ? img.rows : img_row) diff --git a/lib/sisu/v5/db_create.rb b/lib/sisu/v5/db_create.rb index 956a470a..19e81998 100644 --- a/lib/sisu/v5/db_create.rb +++ b/lib/sisu/v5/db_create.rb @@ -117,10 +117,38 @@ module SiSU_DbCreate end end def conn_exec_pg(sql) - @conn.exec_params(sql) + begin + @conn.exec_params(sql) + rescue + if @conn.is_a?(NilClass) + errmsg="No pg connection (check pg dependencies)" + if @opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, proceeding without pg output (as requested)") + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, STOPPING") + exit + end + end + end end def conn_exec_sqlite(sql) + begin @conn.execute(sql) + rescue + if @conn.is_a?(NilClass) + errmsg="No sqlite3 connection (check sqlite3 dependencies)" + if @opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, proceeding without sqlite output (as requested)") + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, STOPPING") + exit + end + end + end end def metadata_and_text if (@opt.act[:verbose_plus][:set]==:on \ diff --git a/lib/sisu/v5/db_indexes.rb b/lib/sisu/v5/db_indexes.rb index b76e4b26..a27deb67 100644 --- a/lib/sisu/v5/db_indexes.rb +++ b/lib/sisu/v5/db_indexes.rb @@ -82,9 +82,23 @@ module SiSU_DbIndex end end def conn_execute_array(sql_arr) - @conn.transaction do |conn| - sql_arr.each do |sql| - conn_execute_sql(conn,sql) + begin + @conn.transaction do |conn| + sql_arr.each do |sql| + conn_execute_sql(conn,sql) + end + end + rescue + if @conn.is_a?(NilClass) + errmsg="No sqlite3 connection (check sqlite3 dependencies)" + if @opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, proceeding without sqlite output (as requested)") + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, STOPPING") + exit + end end end end diff --git a/lib/sisu/v5/dbi.rb b/lib/sisu/v5/dbi.rb index 8e27f443..df4b3180 100644 --- a/lib/sisu/v5/dbi.rb +++ b/lib/sisu/v5/dbi.rb @@ -102,7 +102,12 @@ module SiSU_DBI end def read_psql begin - require 'pg' + begin + require 'pg' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('pg NOT FOUND (LoadError)') + end @conn=@db.psql.conn_pg rescue if @opt.act[:psql_create][:set]==:on @@ -119,11 +124,23 @@ manually create the database: "#{cX.green}#{@db.db}#{cX.off}" if it does not yet def read_sqlite begin begin - require 'sqlite3' + begin + require 'sqlite3' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('sqlite3 NOT FOUND (LoadError)') + end @conn=@db.sqlite.conn_sqlite3 rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error('sqlite3 NOT FOUND (LoadError)') + errmsg='sqlite3 NOT FOUND (LoadError)' + if @opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error(errmsg + ', ' + 'attempt to proceed without sqlite output (as requested)') + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error(errmsg + ', ' + 'STOPPING') + exit + end end end end diff --git a/lib/sisu/v5/se_db.rb b/lib/sisu/v5/se_db.rb index fcb5fc0d..84fd6ba6 100644 --- a/lib/sisu/v5/se_db.rb +++ b/lib/sisu/v5/se_db.rb @@ -140,7 +140,12 @@ module SiSU_Info_Db DBI.connect(psql.dbi,psql.user,psql.db) end def conn_pg - require 'pg' + begin + require 'pg' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('pg NOT FOUND (LoadError)') + end PG::Connection.new(dbname: psql.db, port: psql.port) end self diff --git a/lib/sisu/v5/texpdf.rb b/lib/sisu/v5/texpdf.rb index 25ee6eb2..c2c9dc70 100644 --- a/lib/sisu/v5/texpdf.rb +++ b/lib/sisu/v5/texpdf.rb @@ -269,8 +269,16 @@ module SiSU_TeX FileUtils::cp(portrait_pdf,"#{@md.file.output_path.pdf.dir}/#{pdf_p}") FileUtils::rm(portrait_pdf) else - STDERR.puts "#{cX.fuchsia}pdf file not generated#{cX.off} <#{cX.blue}#{portrait_pdf.gsub(/.+?([^\/]+?\.pdf)$/,'\1')}#{cX.off}> (check texlive dependencies)" STDERR.puts "#{__FILE__}:#{__LINE__} NOT FOUND: #{portrait_pdf}" if @md.opt.act[:maintenance][:set]==:on + errmsg="pdf file not generated #{portrait_pdf.gsub(/.+?([^\/]+?\.pdf)$/,'\1')} (check texlive dependencies)" + if @md.opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, proceeding without pdf output (as requested)") + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, STOPPING") + exit + end end end if @md.opt.act[:pdf_l][:set]==:on @@ -278,8 +286,16 @@ module SiSU_TeX FileUtils::cp(landscape_pdf,"#{@md.file.output_path.pdf.dir}/#{pdf_l}") FileUtils::rm(landscape_pdf) else - STDERR.puts "#{cX.fuchsia}pdf file not generated#{cX.off} <#{cX.blue}#{landscape_pdf.gsub(/.+?([^\/]+?\.pdf)$/,'\1')}#{cX.off}> (check texlive dependencies)" STDERR.puts "#{__FILE__}:#{__LINE__} NOT FOUND: #{landscape_pdf}" if @md.opt.act[:maintenance][:set]==:on + errmsg="pdf file not generated #{landscape_pdf.gsub(/.+?([^\/]+?\.pdf)$/,'\1')} (check texlive dependencies)" + if @md.opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, proceeding without pdf output (as requested)") + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, STOPPING") + exit + end end end if (@md.opt.act[:verbose][:set]==:on \ @@ -314,7 +330,15 @@ module SiSU_TeX and File.size(texfile) > 0 #@tex_f_no+=1 else - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error("\tzero file size #{@env.processing_path.tex}/#{texfile}") + errmsg="zero file size #{@env.processing_path.tex}/#{texfile}" + if @md.opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, proceeding without pdf output (as requested)") + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, STOPPING") + exit + end end end end diff --git a/lib/sisu/v6/ao_images.rb b/lib/sisu/v6/ao_images.rb index 93ed4d84..e934ec1a 100644 --- a/lib/sisu/v6/ao_images.rb +++ b/lib/sisu/v6/ao_images.rb @@ -134,6 +134,17 @@ module SiSU_AO_Images end img_col,img_row=/(\d+)x(\d+)/m.match(imgsys)[1,2] img_col,img_row=img_col.to_i,img_row.to_i + else + errmsg='imagemagick or graphicksmagick are required to process images' + if @md.opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, proceeding (as requested) without image processing") + break + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, STOPPING") + exit + end end end row=((img && defined? img.rows) ? img.rows : img_row) diff --git a/lib/sisu/v6/db_create.rb b/lib/sisu/v6/db_create.rb index 55eab144..a9083b61 100644 --- a/lib/sisu/v6/db_create.rb +++ b/lib/sisu/v6/db_create.rb @@ -117,10 +117,38 @@ module SiSU_DbCreate end end def conn_exec_pg(sql) - @conn.exec_params(sql) + begin + @conn.exec_params(sql) + rescue + if @conn.is_a?(NilClass) + errmsg="No pg connection (check pg dependencies)" + if @opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, proceeding without pg output (as requested)") + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, STOPPING") + exit + end + end + end end def conn_exec_sqlite(sql) + begin @conn.execute(sql) + rescue + if @conn.is_a?(NilClass) + errmsg="No sqlite3 connection (check sqlite3 dependencies)" + if @opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, proceeding without sqlite output (as requested)") + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, STOPPING") + exit + end + end + end end def metadata_and_text if (@opt.act[:verbose_plus][:set]==:on \ diff --git a/lib/sisu/v6/db_indexes.rb b/lib/sisu/v6/db_indexes.rb index 876fd856..12c427dd 100644 --- a/lib/sisu/v6/db_indexes.rb +++ b/lib/sisu/v6/db_indexes.rb @@ -82,9 +82,23 @@ module SiSU_DbIndex end end def conn_execute_array(sql_arr) - @conn.transaction do |conn| - sql_arr.each do |sql| - conn_execute_sql(conn,sql) + begin + @conn.transaction do |conn| + sql_arr.each do |sql| + conn_execute_sql(conn,sql) + end + end + rescue + if @conn.is_a?(NilClass) + errmsg="No sqlite3 connection (check sqlite3 dependencies)" + if @opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, proceeding without sqlite output (as requested)") + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, STOPPING") + exit + end end end end diff --git a/lib/sisu/v6/dbi.rb b/lib/sisu/v6/dbi.rb index 7b68be2f..47173d4f 100644 --- a/lib/sisu/v6/dbi.rb +++ b/lib/sisu/v6/dbi.rb @@ -102,7 +102,12 @@ module SiSU_DBI end def read_psql begin - require 'pg' + begin + require 'pg' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('pg NOT FOUND (LoadError)') + end @conn=@db.psql.conn_pg rescue if @opt.act[:psql_create][:set]==:on @@ -119,11 +124,23 @@ manually create the database: "#{cX.green}#{@db.db}#{cX.off}" if it does not yet def read_sqlite begin begin - require 'sqlite3' + begin + require 'sqlite3' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('sqlite3 NOT FOUND (LoadError)') + end @conn=@db.sqlite.conn_sqlite3 rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error('sqlite3 NOT FOUND (LoadError)') + errmsg='sqlite3 NOT FOUND (LoadError)' + if @opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error(errmsg + ', ' + 'attempt to proceed without sqlite output (as requested)') + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error(errmsg + ', ' + 'STOPPING') + exit + end end end end diff --git a/lib/sisu/v6/se_db.rb b/lib/sisu/v6/se_db.rb index ac226675..abf80b32 100644 --- a/lib/sisu/v6/se_db.rb +++ b/lib/sisu/v6/se_db.rb @@ -140,7 +140,12 @@ module SiSU_Info_Db DBI.connect(psql.dbi,psql.user,psql.db) end def conn_pg - require 'pg' + begin + require 'pg' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('pg NOT FOUND (LoadError)') + end PG::Connection.new(dbname: psql.db, port: psql.port) end self diff --git a/lib/sisu/v6/texpdf.rb b/lib/sisu/v6/texpdf.rb index df6e96e2..10bfa961 100644 --- a/lib/sisu/v6/texpdf.rb +++ b/lib/sisu/v6/texpdf.rb @@ -269,8 +269,16 @@ module SiSU_TeX FileUtils::cp(portrait_pdf,"#{@md.file.output_path.pdf.dir}/#{pdf_p}") FileUtils::rm(portrait_pdf) else - STDERR.puts "#{cX.fuchsia}pdf file not generated#{cX.off} <#{cX.blue}#{portrait_pdf.gsub(/.+?([^\/]+?\.pdf)$/,'\1')}#{cX.off}> (check texlive dependencies)" STDERR.puts "#{__FILE__}:#{__LINE__} NOT FOUND: #{portrait_pdf}" if @md.opt.act[:maintenance][:set]==:on + errmsg="pdf file not generated #{portrait_pdf.gsub(/.+?([^\/]+?\.pdf)$/,'\1')} (check texlive dependencies)" + if @md.opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, proceeding without pdf output (as requested)") + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, STOPPING") + exit + end end end if @md.opt.act[:pdf_l][:set]==:on @@ -278,8 +286,16 @@ module SiSU_TeX FileUtils::cp(landscape_pdf,"#{@md.file.output_path.pdf.dir}/#{pdf_l}") FileUtils::rm(landscape_pdf) else - STDERR.puts "#{cX.fuchsia}pdf file not generated#{cX.off} <#{cX.blue}#{landscape_pdf.gsub(/.+?([^\/]+?\.pdf)$/,'\1')}#{cX.off}> (check texlive dependencies)" STDERR.puts "#{__FILE__}:#{__LINE__} NOT FOUND: #{landscape_pdf}" if @md.opt.act[:maintenance][:set]==:on + errmsg="pdf file not generated #{landscape_pdf.gsub(/.+?([^\/]+?\.pdf)$/,'\1')} (check texlive dependencies)" + if @md.opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, proceeding without pdf output (as requested)") + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, STOPPING") + exit + end end end if (@md.opt.act[:verbose][:set]==:on \ @@ -314,7 +330,15 @@ module SiSU_TeX and File.size(texfile) > 0 #@tex_f_no+=1 else - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error("\tzero file size #{@env.processing_path.tex}/#{texfile}") + errmsg="zero file size #{@env.processing_path.tex}/#{texfile}" + if @md.opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, proceeding without pdf output (as requested)") + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, STOPPING") + exit + end end end end -- cgit v1.2.3