diff options
author | Ralph Amissah <ralph@amissah.com> | 2014-08-20 19:04:47 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2014-08-20 19:04:47 -0400 |
commit | 29fc7f3c14b36770caad64cb82ec9177384ab61a (patch) | |
tree | c2079e8bf5d2944d7bc10b55c1b3fb76dcb07cc0 | |
parent | v5 v6: hub options, introduce "error override" --no-stop or --errors-as-warnings (diff) |
v5 v6: start making use of --no-stop command
-rw-r--r-- | data/doc/sisu/CHANGELOG_v5 | 2 | ||||
-rw-r--r-- | data/doc/sisu/CHANGELOG_v6 | 1 | ||||
-rw-r--r-- | lib/sisu/v5/ao_images.rb | 11 | ||||
-rw-r--r-- | lib/sisu/v5/db_create.rb | 30 | ||||
-rw-r--r-- | lib/sisu/v5/db_indexes.rb | 20 | ||||
-rw-r--r-- | lib/sisu/v5/dbi.rb | 25 | ||||
-rw-r--r-- | lib/sisu/v5/se_db.rb | 7 | ||||
-rw-r--r-- | lib/sisu/v5/texpdf.rb | 30 | ||||
-rw-r--r-- | lib/sisu/v6/ao_images.rb | 11 | ||||
-rw-r--r-- | lib/sisu/v6/db_create.rb | 30 | ||||
-rw-r--r-- | lib/sisu/v6/db_indexes.rb | 20 | ||||
-rw-r--r-- | lib/sisu/v6/dbi.rb | 25 | ||||
-rw-r--r-- | lib/sisu/v6/se_db.rb | 7 | ||||
-rw-r--r-- | lib/sisu/v6/texpdf.rb | 30 |
14 files changed, 225 insertions, 24 deletions
diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 714c6cc3..d1609df6 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -39,11 +39,13 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.6.2.orig.tar.xz sisu_5.6.2-1.dsc * hub_options, introduce "error override" --no-stop or --errors-as-warnings flag +* start making use of --no-stop command * ao * book index related * ao_expand_insertions, blocked text match, adjust + * texpdf, output, copyright & license * syntax hilighting, restrict heading matches, minor diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 8661c834..7b3e3492 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -29,6 +29,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.2.3.orig.tar.xz sisu_6.2.3-1.dsc * hub_options, introduce "error override" --no-stop or --errors-as-warnings flag +* start making use of --no-stop command * ao * book index related 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 |