From 06520be4633f7ee3463c92615be3e11f0f21fa08 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 21 Apr 2012 01:47:35 -0400 Subject: v3: db bugfix in maintenance mode (variable name reused) --- lib/sisu/v3/db_import.rb | 24 ++++++++++++------------ lib/sisu/v3/db_load_tuple.rb | 36 ++++++++++++++++++------------------ lib/sisu/v3/db_select.rb | 12 ++++++------ lib/sisu/v3/dbi_discreet.rb | 22 +++++++++++++++++++--- 4 files changed, 55 insertions(+), 39 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/db_import.rb b/lib/sisu/v3/db_import.rb index 3bb6e210..e4f90e1d 100644 --- a/lib/sisu/v3/db_import.rb +++ b/lib/sisu/v3/db_import.rb @@ -69,8 +69,8 @@ module SiSU_DbImport @@dl=nil @@hname=nil attr_accessor :tp - def initialize(opt,conn,file,sql_type='pg') - @opt,@conn,@file,@sql_type=opt,conn,file,sql_type + def initialize(opt,conn,file_maint,sql_type='pg') + @opt,@conn,@file_maint,@sql_type=opt,conn,file_maint,sql_type @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX @env=SiSU_Env::InfoEnv.new(@opt.fns) @dal="#{@env.processing_path.dal}" @@ -239,7 +239,7 @@ module SiSU_DbImport end ################ CLEAR ############## SiSU_DbDBI::Test.new(self,@opt).verify #% import title names, filenames (tuple) - t=SiSU_DbTuple::LoadMetadata.new(@conn,@@id_t,@md,@file) + t=SiSU_DbTuple::LoadMetadata.new(@conn,@@id_t,@md,@file_maint) tuple=t.tuple tuple end @@ -283,7 +283,7 @@ module SiSU_DbImport end if @en_pls[0]; @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last end - t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) + t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint) @tuple_array << t.tuple case @col[:lev] when /1/; @col[:lv1]+=1 @@ -314,7 +314,7 @@ module SiSU_DbImport @en_a,@en_z=@en[0].first,@en[0].last if @en[0] @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) + t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint) @tuple_array << t.tuple @col[:lev]=@col[:plaintext]=@col[:body]='' elsif data.is==:heading \ @@ -344,7 +344,7 @@ module SiSU_DbImport @en_a,@en_z=@en[0].first,@en[0].last if @en[0] @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) + t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint) @tuple_array << t.tuple @col[:lev]=@col[:plaintext]=@col[:body]='' elsif data.is==:heading \ @@ -372,7 +372,7 @@ module SiSU_DbImport @en_a,@en_z=@en[0].first,@en[0].last if @en[0] @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) + t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint) @tuple_array << t.tuple @col[:lev]=@col[:plaintext]=@col[:body]='' elsif data.of==:structure \ @@ -423,7 +423,7 @@ module SiSU_DbImport @col[:plaintext]=@col[:body].dup @col[:plaintext]=strip_markup(@col[:plaintext]) @col[:plaintext]=clean_searchable_text(@col[:plaintext]) - t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) + t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint) @tuple_array << t.tuple @en,@en_ast,@en_pls=[],[],[] @col[:en_a]=@col[:en_z]=nil @@ -461,7 +461,7 @@ module SiSU_DbImport id_t: @@id_t, hash: digest_clean } - t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file) + t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file_maint) @tuple_array << t.tuple end end @@ -500,7 +500,7 @@ module SiSU_DbImport id_t: @@id_t, hash: digest_clean } - t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file) + t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file_maint) @tuple_array << t.tuple end end @@ -539,7 +539,7 @@ module SiSU_DbImport id_t: @@id_t, hash: digest_clean } - t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file) + t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file_maint) @tuple_array << t.tuple end end @@ -678,7 +678,7 @@ module SiSU_DbImport if FileTest.file?("#{@md.file.output_path.sisupod.dir}/#{@md.file.base_filename.sisupod}")==true f[:sisupod],u[:sisupod]='sisupod,', "'#{@md.file.output_path.sisupod.url}/#{@md.file.base_filename.sisupod}'," end - t=SiSU_DbTuple::LoadUrls.new(@conn,f,u,@@id_t,@opt,@file) + t=SiSU_DbTuple::LoadUrls.new(@conn,f,u,@@id_t,@opt,@file_maint) tuple=t.tuple rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure diff --git a/lib/sisu/v3/db_load_tuple.rb b/lib/sisu/v3/db_load_tuple.rb index c3273ace..5b263411 100644 --- a/lib/sisu/v3/db_load_tuple.rb +++ b/lib/sisu/v3/db_load_tuple.rb @@ -62,8 +62,8 @@ module SiSU_DbTuple class LoadDocuments require_relative 'param' # param.rb include SiSU_Param - def initialize(conn,col,opt,file) - @conn,@col,@opt,@file=conn,col,opt,file + def initialize(conn,col,opt,file_maint) + @conn,@col,@opt,@file_maint=conn,col,opt,file_maint @col[:lev]=@col[:lev].to_i unless @col[:lev]=~/^[1-6]/ \ or @col[:lev]==1 \ @@ -87,14 +87,14 @@ module SiSU_DbTuple end if @opt.cmd =~/M/ if @opt.cmd =~/V/ - puts @file.inspect + puts @file_maint.inspect puts sql_entry end - @file.puts sql_entry + @file_maint.puts sql_entry else if @opt.cmd =~/V/ puts sql_entry - @file.puts sql_entry + @file_maint.puts sql_entry end end if @opt.cmd =~/v/ @@ -115,8 +115,8 @@ module SiSU_DbTuple end end class LoadMetadata #< SiSU_DbColumns::Columns - def initialize(conn,id,md,file) - @conn,@id,@md,@file=conn,id,md,file + def initialize(conn,id,md,file_maint) + @conn,@id,@md,@file_maint=conn,id,md,file_maint @tp=SiSU_DbColumns::Columns.new(md) end def tuple @@ -291,40 +291,40 @@ tid) #{@id} );" if @md.opt.cmd =~/M/ - puts "maintenance mode on: creating sql transaction file (for last transaction set (document) only):\n\t#{@file.inspect}" - @file.puts sql_entry + puts "maintenance mode on: creating sql transaction file (for last transaction set (document) only):\n\t#{@file_maint.inspect}" + @file_maint.puts sql_entry else - @file.puts sql_entry if @md.opt.cmd =~/V/ + @file_maint.puts sql_entry if @md.opt.cmd =~/V/ end sql_entry end end class LoadUrls - def initialize(conn,f,u,id,opt,file) - @conn,@f,@u,@id,@opt,@file=conn,f,u,id,opt,file + def initialize(conn,f,u,id,opt,file_maint) + @conn,@f,@u,@id,@opt,@file_maint=conn,f,u,id,opt,file_maint end def tuple sql_entry="INSERT INTO urls (#{@f[:txt]} #{@f[:html_toc]} #{@f[:html_doc]} #{@f[:xhtml]} #{@f[:xml_sax]} #{@f[:xml_dom]} #{@f[:odf]} #{@f[:pdf_p]} #{@f[:pdf_l]} #{@f[:concordance]} #{@f[:latex_p]} #{@f[:latex_l]} #{@f[:manifest]} #{@f[:digest]} #{@f[:markup]} #{@f[:sisupod]} metadata_tid) " + "VALUES (#{@u[:txt]} #{@u[:html_toc]} #{@u[:html_doc]} #{@u[:xhtml]} #{@u[:xml_sax]} #{@u[:xml_dom]} #{@u[:odf]} #{@u[:pdf_p]} #{@u[:pdf_l]} #{@u[:concordance]} #{@u[:latex_p]} #{@u[:latex_l]} #{@u[:manifest]} #{@u[:digest]} #{@u[:markup]} #{@u[:sisupod]} #{@id});" if @opt.cmd =~/M/ - @file.puts sql_entry + @file_maint.puts sql_entry else - @file.puts sql_entry if @opt.cmd =~/V/ + @file_maint.puts sql_entry if @opt.cmd =~/V/ end sql_entry end end class LoadEndnotes - def initialize(conn,en,opt,file) - @conn,@en,@opt,@file=conn,en,opt,file + def initialize(conn,en,opt,file_maint) + @conn,@en,@opt,@file_maint=conn,en,opt,file_maint end def tuple sql_entry="INSERT INTO #{@en[:type]} (nid, document_lid, nr, clean, body, ocn, ocnd, ocns, metadata_tid, digest_clean) " + "VALUES ('#{@en[:id]}', '#{@en[:lid]}', '#{@en[:nr]}', '#{@en[:txt]}', '#{@en[:body]}', '#{@en[:ocn]}', '#{@en[:ocnd]}', '#{@en[:ocns]}', '#{@en[:id_t]}', '#{@en[:hash]}');" if @opt.cmd =~/M/ - @file.puts sql_entry + @file_maint.puts sql_entry else - @file.puts sql_entry if @opt.cmd =~/V/ + @file_maint.puts sql_entry if @opt.cmd =~/V/ end sql_entry end diff --git a/lib/sisu/v3/db_select.rb b/lib/sisu/v3/db_select.rb index 52fbe8ba..ec6c91dc 100644 --- a/lib/sisu/v3/db_select.rb +++ b/lib/sisu/v3/db_select.rb @@ -62,15 +62,15 @@ module SiSU_DbSelect def initialize(opt,conn='',sql_type='pg') @opt,@conn,@sql_type=opt,conn,sql_type @db=SiSU_Env::InfoDb.new - @file=sql_maintenance_file - @sdb=SiSU_DbDBI::Create.new(@opt,@conn,@file,@sql_type) # db_dbi.rb - @sdb_index=SiSU_DbDBI::Index.new(@opt,@conn,@file,@sql_type) # db_dbi.rb + @file_maint=sql_maintenance_file + @sdb=SiSU_DbDBI::Create.new(@opt,@conn,@file_maint,@sql_type) # db_dbi.rb + @sdb_index=SiSU_DbDBI::Index.new(@opt,@conn,@file_maint,@sql_type) # db_dbi.rb @sdb_no=SiSU_DbDBI::Drop.new(@opt,@conn,@db,@sql_type) # db_dbi.rb if @opt.mod.inspect =~/update|import/ - @sdb_import=SiSU_DbDBI::Import.new(@opt,@conn,@file,@sql_type) - @sdb_remove_doc=SiSU_DbDBI::Remove.new(@opt,@conn,@file,@sql_type) + @sdb_import=SiSU_DbDBI::Import.new(@opt,@conn,@file_maint,@sql_type) + @sdb_remove_doc=SiSU_DbDBI::Remove.new(@opt,@conn,@file_maint,@sql_type) elsif @opt.mod.inspect =~/remove/ - @sdb_remove_doc=SiSU_DbDBI::Remove.new(@opt,@conn,@file,@sql_type) + @sdb_remove_doc=SiSU_DbDBI::Remove.new(@opt,@conn,@file_maint,@sql_type) end end def db_exist? diff --git a/lib/sisu/v3/dbi_discreet.rb b/lib/sisu/v3/dbi_discreet.rb index 61ab3a3d..8f7f0c53 100644 --- a/lib/sisu/v3/dbi_discreet.rb +++ b/lib/sisu/v3/dbi_discreet.rb @@ -81,6 +81,7 @@ module SiSU_DBI_Discreet #% database building end @output_path=@md.file.output_path.sqlite_discreet.dir @filename=@md.file.base_filename.sqlite_discreet + @file_maint=sql_maintenance_file @file="#{@output_path}/#{@filename}" end def build @@ -114,8 +115,8 @@ module SiSU_DBI_Discreet #% database building def create_and_populate db=SiSU_Env::DbOp.new(@md) conn=db.sqlite_discreet.conn_sqlite3 - sdb=SiSU_DbDBI::Create.new(@opt,conn,@file,'sqlite') - sdb_index=SiSU_DbDBI::Index.new(@opt,conn,@file,'sqlite') + sdb=SiSU_DbDBI::Create.new(@opt,conn,@file_maint,'sqlite') + sdb_index=SiSU_DbDBI::Index.new(@opt,conn,@file_maint,'sqlite') sdb.output_dir? begin SiSU_Screen::Ansi.new(@opt.cmd,'SQLite',"[#{@opt.f_pth[:lng_is]}] #{@opt.fns}").green_title_hi unless @opt.cmd =~/q/ @@ -128,7 +129,7 @@ module SiSU_DBI_Discreet #% database building sdb.create_table.urls sdb_index.create_indexes db_exist?(db,conn) - sdb_import=SiSU_DbDBI::Import.new(@opt,conn,@file,'sqlite') + sdb_import=SiSU_DbDBI::Import.new(@opt,conn,@file_maint,'sqlite') sdb_import.marshal_load tell=SiSU_Screen::Ansi.new(@opt.cmd,"sqlite3 #{db.sqlite.db} database?") tell.puts_grey if @opt.cmd =~/v/ @@ -154,6 +155,21 @@ module SiSU_DBI_Discreet #% database building end def populate end + def sql_maintenance_file + file=if @opt.inspect =~/M/ + x=if @opt.fns and not @opt.fns.empty? + @env=SiSU_Env::InfoEnv.new(@opt.fns) if @opt.fns + puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" if @sql_type =~/sqlite/ and @opt.cmd =~/M/ + @db=SiSU_Env::InfoDb.new + @job="sqlite3 #{@db.sqlite.db} < #{@env.processing_path.sqlite}/#{@opt.fns}.sql" + File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+') + elsif @opt.fns and @opt.fns.inspect =~/create/; nil #sort variations later + else nil + end + else nil + end + file + end end end __END__ -- cgit v1.2.3 From 5ae11e06f0ca7605a29876a3d840ac8c88f1f40d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 21 Apr 2012 01:50:23 -0400 Subject: v3: sysenv, default processing dir name change * distinguish sisu branch, add sisu branch to processing directory name * if constants, 'DEVELOPER[:maintenance] == :true' then additionally add sisu version number to processing directory name --- lib/sisu/v3/constants.rb | 3 +++ lib/sisu/v3/sysenv.rb | 15 +++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/constants.rb b/lib/sisu/v3/constants.rb index 439dee68..c7a5c539 100644 --- a/lib/sisu/v3/constants.rb +++ b/lib/sisu/v3/constants.rb @@ -242,6 +242,9 @@ DISABLE={ ncx_navpoint_unique_id: true, }, } +DEVELOPER={ + maintenance: :false, +} __END__ consider: 〔comment〕 diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 442795c9..88ee8ccf 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -101,7 +101,7 @@ module SiSU_Env data=Config::CONFIG['datadir'] + '/doc/sisu' m=/.+\/(?:src\/)?(\S+)/m # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m @stub_pwd ||=@@pwd[m,1] - prcss_dir='_sisu_processing_' + prcss_dir='_sisu_processing_' + '.' + SiSU_version_dir prcss_dir_tmp_root="/tmp/#{prcss_dir}" prcss_dir_stub="#{prcss_dir}/#{@stub_pwd}" if @@user @@ -2018,16 +2018,19 @@ WOK @rc['processing']['dir'] else defaults[:processing_dir] end + v=SiSU_Env::InfoVersion.instance.get_version + v_dev=(DEVELOPER[:maintenance]==:true) \ + ? "_#{v[:version]}" + : '' path=if proposed_path_base \ and FileTest.directory?(proposed_path_base) \ and File.writable?("#{proposed_path_base}/.") - x=if proposed_dir - "#{proposed_path_base}/#{proposed_dir}" - else - "#{proposed_path_base}/#{defaults[:processing_dir]}" - end + x=proposed_dir \ + ? "#{proposed_path_base}/#{proposed_dir}" + : "#{proposed_path_base}/#{defaults[:processing_dir]}" else defaults[:processing_dir_tmp_root] end + path = path + v_dev end def usr_dir? case root_dir -- cgit v1.2.3 From d810b3f1a2c26f07cd224cfc23339b5ac0bdd26f Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 21 Apr 2012 01:54:22 -0400 Subject: v3: rescue reporting --- lib/sisu/v3/errors.rb | 23 ++++++++++++++--------- lib/sisu/v3/hub.rb | 6 +++++- lib/sisu/v3/screen_text_color.rb | 2 +- lib/sisu/v3/sysenv.rb | 25 ++++++++++++++++++++----- lib/sisu/v3/texinfo.rb | 5 ++++- 5 files changed, 44 insertions(+), 17 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/errors.rb b/lib/sisu/v3/errors.rb index 25ef688c..f0333334 100644 --- a/lib/sisu/v3/errors.rb +++ b/lib/sisu/v3/errors.rb @@ -62,18 +62,23 @@ module SiSU_Errors class InfoError