aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v5
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-08-20 19:04:47 -0400
committerRalph Amissah <ralph@amissah.com>2014-08-20 19:04:47 -0400
commit29fc7f3c14b36770caad64cb82ec9177384ab61a (patch)
treec2079e8bf5d2944d7bc10b55c1b3fb76dcb07cc0 /lib/sisu/v5
parentv5 v6: hub options, introduce "error override" --no-stop or --errors-as-warnings (diff)
v5 v6: start making use of --no-stop command
Diffstat (limited to 'lib/sisu/v5')
-rw-r--r--lib/sisu/v5/ao_images.rb11
-rw-r--r--lib/sisu/v5/db_create.rb30
-rw-r--r--lib/sisu/v5/db_indexes.rb20
-rw-r--r--lib/sisu/v5/dbi.rb25
-rw-r--r--lib/sisu/v5/se_db.rb7
-rw-r--r--lib/sisu/v5/texpdf.rb30
6 files changed, 111 insertions, 12 deletions
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