view · edit · sidebar · attach · print · history

20110120-update-rpdf2txt-setup-ramaze

<< Masa.20110121-setup-ramaze | 2011 | Masa.20110119-update-rpdf2txt >>


  1. Update rpdf2txt
  2. Test importer oddb.org (ch.oddb.org)
  3. Short summary of different points between Ruby 1.8 and 1.9
  4. Set up the ramaze version of oddb.org suspend
  5. Debug rpdf2txt on Ruby 1.9
  6. Resume set up ramaze oddb.org

Goal
  • Update rpdf2txt for Ruby1.9 / 100%
  • Setup Ramaze version oddb / 30%
Milestones
  • Complete Test-cases rpdf2txt 8:30
  • Local test importer oddb.org
  • Commit rpdf2txt 14:00
  • Set up ramaze version oddb
Summary
Commits
ToDo Tomorrow
Keep in Mind
  1. Encoding woes (from Davatz-san)
  2. Feedback: This option indicates that the regular expression is parsed as 'UTF8' (from Davatz-san)
  3. pg on Ubuntu - see http://dev.ywesee.com/wiki.php/Gem/Pg (from Davatz-san)
  4. On Ice
  5. emerge --sync

Update rpdf2txt

The last failure

masa@masa ~/ywesee/rpdf2txt $ ruby1.9 -I lib test/test_pdf_parser.rb 
  1) Failure:
test_join_snippets__hex_chars(TestParser) [test/test_pdf_parser.rb:337]:
<"Paroxetin besitzt eine selektive Wirkung; in-vitro Studien haben gezeigt, dass es, im Gegensatz zu\ntrizyklischen Antidepressiva, eine geringe Affinit\xE4t f\xFCr  a1-, a2- und b-Adrenozeptoren sowie f\xFCr\nDopamin (D2)-, 5-HT1-artige, 5-HT2 und Histamin (H1)-Rezeptoren aufweist. Das Fehlen einer\n"> expected but was
<"Paroxetin besitzt eine selektive Wirkung; in-vitro Studien haben gezeigt, dass es, im Gegensatz zu\ntrizyklischen Antidepressiva, eine geringe Affinit\xE4t f\xFCr a1-, a2- und b-Adrenozeptoren sowie f\xFCr\nDopamin (D2)-, 5-HT1-artige, 5-HT2 und Histamin (H1)-Rezeptoren aufweist. Das Fehlen einer\n">

Note

  • Only one space is lack

Change a test code (delete one space) test/test_pdf_parser.rb#est_join_snippets__hex_chars

Paroxetin besitzt eine selektive Wirkung; in-vitro Studien haben gezeigt, dass es, im Gegensatz zu
trizyklischen Antidepressiva, eine geringe Affinit\344t f\374r a1-, a2- und b-Adrenozeptoren sowie f\374r
Dopamin (D2)-, 5-HT1-artige, 5-HT2 und Histamin (H1)-Rezeptoren aufweist. Das Fehlen einer

Result

Ruby 1.8 with the latest libraries

masa@masa ~/ywesee/rpdf2txt $ ruby18 -I ~/work/rpdf2txt/lib test/suite.rb 
Loaded suite test/suite
Started
......................'invalid literal/lengths set' when filtering with /FlateDecode
...................................................................unknown encoding 370 0 R
........F..............
Finished in 8.873084 seconds.

  1) Failure:
test_join_snippets__hex_chars(TestParser) [/home/masa/ywesee/rpdf2txt/test/test_pdf_parser.rb:337]:
<"Paroxetin besitzt eine selektive Wirkung; in-vitro Studien haben gezeigt, dass es, im Gegensatz zu\ntrizyklischen Antidepressiva, eine geringe Affinit&#65533; f&#65533; a1-, a2- und b-Adrenozeptoren sowie f&#65533;
Dopamin (D2)-, 5-HT1-artige, 5-HT2 und Histamin (H1)-Rezeptoren aufweist. Das Fehlen einer\n"> expected but was
<"Paroxetin besitzt eine selektive Wirkung; in-vitro Studien haben gezeigt, dass es, im Gegensatz zu\ntrizyklischen Antidepressiva, eine geringe Affinit&#65533; f&#65533;  a1-, a2- und b-Adrenozeptoren sowie f&#65533;
Dopamin (D2)-, 5-HT1-artige, 5-HT2 und Histamin (H1)-Rezeptoren aufweist. Das Fehlen einer\n">.

112 tests, 227 assertions, 1 failures, 0 errors

Ruby 1.8 with the updated libraries

masa@masa ~/ywesee/rpdf2txt $ ruby18 -I lib test/suite.rb 
Loaded suite test/suite
Started
......................'invalid literal/lengths set' when filtering with /FlateDecode
...................................................................unknown encoding 370 0 R
.......................
Finished in 8.914007 seconds.

112 tests, 227 assertions, 0 failures, 0 errors

Ruby 1.9 with the updated libraries

masa@masa ~/ywesee/rpdf2txt $ ruby1.9 -I lib test/suite.rb 
test/suite.rb:26: warning: variable $KCODE is no longer effective; ignored
/home/masa/ywesee/rpdf2txt/test/test_pdf_object.rb:26: warning: variable $KCODE is no longer effective; ignored
/home/masa/ywesee/rpdf2txt/test/test_pdf_parser.rb:28: warning: variable $KCODE is no longer effective; ignored
Loaded suite test/suite
Started
......................'invalid literal/lengths set' when filtering with /FlateDecode
.........................................................
..........unknown encoding 370 0 R
.......................

Finished in 7.409007228 seconds.

112 tests, 227 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Test importer oddb.org (ch.oddb.org)

Test import_gkv with the latest rpdf2txt

Load de.oddb.org data on 20110116

masa@masa ~/ywesee $ sudo -u postgres dropdb oddb
masa@masa ~/ywesee $ sudo -u postgres createdb -E UTF8 -T template0 oddb
masa@masa ~/ywesee $ zcat de.oddb.org/data/sql/oddb.20110116.sql.gz | psql -U postgres oddb

Run de.oddb.org

Run jobs/import_gkv

Result

Thu Jan 20 08:52:49 2011: de.oddb.org ODDB::Import::Gkv#import
Imported  6308 Zubef-Entries on 20.01.2011:
Visited   5956 existing Zubef-Entries
Visited   2993 existing Companies
Visited   1449 existing Substances
Created    352 new Zubef-Entries
Created     11 new Products
Created     11 new Sequences
Created   3315 new Companies
Created   3490 new Substances
Assigned     0 Chemical Equivalences
Assigned     7 Companies
Created      4 Incomplete Packages:
http://de.oddb.org/de/drugs/package/pzn/6947611
http://de.oddb.org/de/drugs/package/pzn/6922692
http://de.oddb.org/de/drugs/package/pzn/6907333
http://de.oddb.org/de/drugs/package/pzn/6907327
Created      1 Product(s) without a name (missing product name):
http://de.oddb.org/de/drugs/product/uid/3480899

Dump data and check size

masa@masa ~/ywesee/de.oddb.org $ pg_dump oddb > oddb_old_rpdf2txt.sql
masa@masa ~/ywesee/de.oddb.org $ ls -al
-rw-r--r--  1 masa masa 1845079867 20. Jan 10:57 oddb_old_rpdf2txt.sql

Install the new rpdf2txt

masa@masa ~/ywesee/rpdf2txt $ ruby install.rb config
masa@masa ~/ywesee/rpdf2txt $ ruby install.rb setup
masa@masa ~/ywesee/rpdf2txt $ sudo ruby install.rb install

Check test-cases

masa@masa ~/ywesee/rpdf2txt $ ruby18 test/suite.rb 
Loaded suite test/suite
Started
......................'invalid literal/lengths set' when filtering with /FlateDecode
...................................................................unknown encoding 370 0 R
.............................................
Finished in 12.362712 seconds.

134 tests, 295 assertions, 0 failures, 0 errors

masa@masa ~/ywesee/rpdf2txt $ ruby1.9 -I /usr/lib64/ruby/site_ruby/1.8 test/suite.rb 
test/suite.rb:26: warning: variable $KCODE is no longer effective; ignored
/home/masa/ywesee/rpdf2txt/test/test_pdf_object.rb:26: warning: variable $KCODE is no longer effective; ignored
/home/masa/ywesee/rpdf2txt/test/test_pdf_parser.rb:28: warning: variable $KCODE is no longer effective; ignored
Loaded suite test/suite
Started
......................'invalid literal/lengths set' when filtering with /FlateDecode
.........................................................
..........unknown encoding 370 0 R
.............................................

Finished in 9.37691039 seconds.

134 tests, 295 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Note

  • The new rpdf2txt library is certainly installed

Load de.oddb.org data on 20110116

masa@masa ~/ywesee $ sudo -u postgres dropdb oddb
masa@masa ~/ywesee $ sudo -u postgres createdb -E UTF8 -T template0 oddb
masa@masa ~/ywesee $ zcat de.oddb.org/data/sql/oddb.20110116.sql.gz | psql -U postgres oddb

Run de.oddb.org

Run jobs/import_gkv

Result

Thu Jan 20 11:24:20 2011: de.oddb.org ODDB::Import::Gkv#import
Imported  6308 Zubef-Entries on 20.01.2011:
Visited   5956 existing Zubef-Entries
Visited   2993 existing Companies
Visited   1449 existing Substances
Created    352 new Zubef-Entries
Created     11 new Products
Created     11 new Sequences
Created   3315 new Companies
Created   3490 new Substances
Assigned     0 Chemical Equivalences
Assigned     7 Companies
Created      4 Incomplete Packages:
http://de.oddb.org/de/drugs/package/pzn/6947611
http://de.oddb.org/de/drugs/package/pzn/6922692
http://de.oddb.org/de/drugs/package/pzn/6907333
http://de.oddb.org/de/drugs/package/pzn/6907327
Created      1 Product(s) without a name (missing product name):
http://de.oddb.org/de/drugs/product/uid/3480899

Dump data and check size

masa@masa ~/ywesee/de.oddb.org $ pg_dump oddb > oddb_new_rpdf2txt.sql

Compare the two results

masa@masa ~/work $ diff mail_old_rpdf2txt.txt mail_new_rpdf2txt.txt 
1c1
< Thu Jan 20 08:52:49 2011: de.oddb.org ODDB::Import::Gkv#import
---
> Thu Jan 20 11:24:20 2011: de.oddb.org ODDB::Import::Gkv#import
20d19
< 
masa@masa ~/ywesee/de.oddb.org $ ls -al
-rw-r--r--  1 masa masa 1845079283 20. Jan 13:18 oddb_new_rpdf2txt.sql
-rw-r--r--  1 masa masa 1845079867 20. Jan 10:57 oddb_old_rpdf2txt.sql

Note

  • The report emails are totally same
  • But the dump data sizes are different

Commit

Update git bare repository online

~/git/rpdf2txt $ ls -al /usr/lib64/ruby/site_ruby/1.8/
lrwxrwxrwx  rpdf2txt -> /home/ywesee/git/rpdf2txt/lib/rpdf2txt
lrwxrwxrwx  rpdf2txt-rockit -> /home/ywesee/git/rpdf2txt/lib/rpdf2txt-rockit

~/git/rpdf2txt $ git checkout -f

Short summary of different points between Ruby 1.8 and 1.9

Big difference (Incompatible point)

Multilingualization (m17n)

  • String class
    • Ruby 1.8: Array of bytes
      • include Enumerable => String can be used like an Array)
      • 'String#[0]' returns ascii code
    • Ruby 1.9: encoded characters (not Array but [] method is available)
      • String class behavior changes depending on the encoding
      • 'String#[0]' does not return ascii code (ex. use String#unpack('C*')[0], String.bytes.to_a[0])
      • not include Enumerable module (ex. String#each does not work)
      • we cannot use binary data (byte data) directly through String class
      • we have to set 'ascii-8bit' as an encoding for binary data
  • Magic comment
    • we have to write encoding (magic comment) in each script
    • 'File.read' cannot read binary file anymore (Ruby 1.8 can)
    • ex. instead of 's = File.read("input.dat")'
s = open("input.dat","rb"){|f| f.read}

Careful points from 1.8 to 1.9 (encoding)

  • String#[0] does not return ascii code (this does not output an error, the behavior changes)
  • Put magic comment (encoding) if there are non-ascii characters in source code (in most of the cases, an error comes)
  • Pay attention to the encoding when we use String class, binary data, regular expression
  • We cannot use Enumerable methods for a String instance

References

Set up the ramaze version of oddb.org

References

Copy the directory of ramaze online to my local

masa@masa ~/ywesee/ramaze.ch.oddb.org $ ls -al
insgesamt 64
drwxr-xr-x 12 masa masa  4096 20. Jan 09:38 .
drwxr-xr-x 63 masa masa 20480 20. Jan 09:38 ..
-rw-r--r--  1 masa masa   854 20. Jan 09:38 app.rb
-rwxr-xr-x  1 masa masa   733 20. Jan 09:38 config.ru
drwxr-xr-x  2 masa masa    40 20. Jan 09:38 controller
drwxr-xr-x  2 masa masa    24 20. Jan 09:38 data
drwxr-xr-x  2 masa masa     8 20. Jan 09:38 etc
drwxr-xr-x  2 masa masa    96 20. Jan 09:38 helper
drwxr-xr-x  2 masa masa    16 20. Jan 09:38 layout
drwxr-xr-x  3 masa masa    40 20. Jan 09:38 log
drwxr-xr-x  2 masa masa     8 20. Jan 09:38 model
drwxr-xr-x  5 masa masa    48 20. Jan 09:38 public
drwxr-xr-x  2 masa masa     8 20. Jan 09:38 spec
-rw-r--r--  1 masa masa   407 20. Jan 09:38 start.rb
drwxr-xr-x  4 masa masa    64 20. Jan 09:38 view

Check directory structure

masa@masa ~/ywesee/ramaze.ch.oddb.org $ tree . > ramaze.tree.20101120.txt

Run start.rb

masa@masa ~/ywesee/ramaze.ch.oddb.org $ ruby18 start.rb 
start.rb:6: uninitialized constant Encoding (NameError)

masa@masa ~/ywesee/ramaze.ch.oddb.org $ ruby1.9 start.rb 
/home/masa/ywesee/ramaze.ch.oddb.org/app.rb:7:in `require': no such file to load -- ramaze (LoadError)
        from /home/masa/ywesee/ramaze.ch.oddb.org/app.rb:7:in `<top (required)>'
        from start.rb:7:in `require'
        from start.rb:7:in `<main>'

Note

  • This is only for Ruby 1.9
  • Ruby 1.8 cannot start it

Install ramaze

masa@masa ~/ywesee/ramaze.ch.oddb.org $ sudo ruby1.9 /usr/bin/gem install ramaze
============================================================

Thank you for installing Ramaze!
To create a new project:
$ ramaze create yourproject

============================================================
Successfully installed innate-2010.07
Successfully installed ramaze-2010.06.18
2 gems installed
Installing ri documentation for innate-2010.07...
Installing ri documentation for ramaze-2010.06.18...
Installing RDoc documentation for innate-2010.07...
Installing RDoc documentation for ramaze-2010.06.18...

suspend

Debug rpdf2txt on Ruby 1.9

Errors come in Ruby 1.9 when we use rpdf2txt for the first time.

For example,

masa@masa ~/work $ git clone git://scm.ywesee.com/rpdf2txt
masa@masa ~/work/rpdf2txt $ ruby1.9 -I lib bin/rpdf2txt test/data/test.pdf 
/home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/grammar.rb:82:in `make_element': cannot make an element from nil (ArgumentError)
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/grammar.rb:92:in `block in make_elements'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/grammar.rb:92:in `map'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/grammar.rb:92:in `make_elements'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/grammar.rb:361:in `initialize'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/grammar.rb:484:in `new'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/grammar.rb:484:in `prod'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/rockit_grammar_ast_eval.rb:134:in `block in eval_ast'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/syntax_tree.rb:337:in `map'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/syntax_tree.rb:337:in `rescue in method_missing'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/syntax_tree.rb:333:in `method_missing'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/rockit_grammar_ast_eval.rb:132:in `eval_ast'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/rockit_grammar_ast_eval.rb:129:in `block in eval_ast'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/syntax_tree.rb:337:in `map'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/syntax_tree.rb:337:in `rescue in method_missing'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/syntax_tree.rb:333:in `method_missing'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/rockit_grammar_ast_eval.rb:129:in `eval_ast'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/rockit_grammar_ast_eval.rb:115:in `rockit_productions_eval'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/rockit_grammar_ast_eval.rb:180:in `rockit_grammar_eval'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/rockit.rb:47:in `block in generate_parser_from_file_to_file'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/base_extensions.rb:65:in `call'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/base_extensions.rb:65:in `time_and_puts'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt-rockit/rockit.rb:46:in `generate_parser_from_file_to_file'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/attributesparser.rb:35:in `attributes_parser'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/object.rb:76:in `_parse_attributes'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/object.rb:83:in `parse_attributes'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/object.rb:41:in `initialize'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:114:in `new'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:114:in `build_object'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:132:in `block in build_object_catalogue'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:131:in `scan'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:131:in `build_object_catalogue'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:48:in `object_catalogue'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:163:in `page_tree_root'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:145:in `build_page_tree'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:51:in `page_tree'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:41:in `extract_text'
        from bin/rpdf2txt:61:in `<main>'

Note

  • This is probably because of rpdf2txt-rockit

After the run on Ruby 1.8, an encoding error comes. For example,

masa@masa ~/work/rpdf2txt $ ruby18 -I lib bin/rpdf2txt test/data/test.pdf 

untitled text                                                                        Page 1 of 1
Printed: Donnerstag, 14. November 2002 14:04:29 Uhr
testpdf

masa@masa ~/work/rpdf2txt $ ruby1.9 -I lib bin/rpdf2txt test/data/test.pdf 
/home/masa/work/rpdf2txt/lib/rpdf2txt/attributesparser.rb:38:in `require': /home/masa/work/rpdf2txt/lib/rpdf2txt/data/pdfattributes.rb:9: invalid multibyte char (US-ASCII) (SyntaxError)
/home/masa/work/rpdf2txt/lib/rpdf2txt/data/pdfattributes.rb:9: syntax error, unexpected '~', expecting ')'
    t1 = EofToken.new("EOF",/^(&#65533;~~&#65533;&#65533;~^^~4311922476)/),
                                 ^
/home/masa/work/rpdf2txt/lib/rpdf2txt/data/pdfattributes.rb:9: invalid multibyte char (US-ASCII)
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/attributesparser.rb:38:in `attributes_parser'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/object.rb:76:in `_parse_attributes'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/object.rb:83:in `parse_attributes'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/object.rb:41:in `initialize'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:114:in `new'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:114:in `build_object'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:132:in `block in build_object_catalogue'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:131:in `scan'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:131:in `build_object_catalogue'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:48:in `object_catalogue'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:163:in `page_tree_root'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:145:in `build_page_tree'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:51:in `page_tree'
        from /home/masa/work/rpdf2txt/lib/rpdf2txt/parser.rb:41:in `extract_text'
        from bin/rpdf2txt:61:in `<main>'

Note

  • It seems that rpdf2txt creates some script files under 'data' directory only once rpdf2txt runs for the first time on the environment
  • That is why my updates of magic comments, '# encoding: ascii-8bit', disappear

Commit

Note (IMPORTANT)

 * But this becomes valid only when rpdf2txt runs on Ruby 1.8 for the first time.
 * rpdf2txt must run at least once on Ruby1.8 before it runs on Ruby 1.9.
masa@masa ~/work $ git clone git://scm.ywesee.com/rpdf2txt
Initialized empty Git repository in /home/masa/work/rpdf2txt/.git/
remote: Counting objects: 1390, done.
remote: Compressing objects: 100% (1368/1368), done.
remote: Total 1390 (delta 890), reused 0 (delta 0)
Receiving objects: 100% (1390/1390), 1.24 MiB, done.
Resolving deltas: 100% (890/890), done.
masa@masa ~/work $ cd rpdf2txt
masa@masa ~/work/rpdf2txt $ ruby18 -I lib test/suite.rb 
Loaded suite test/suite
Started
......................'invalid literal/lengths set' when filtering with /FlateDecode
...................................................................unknown encoding 370 0 R
.............................................
Finished in 12.870178 seconds.

134 tests, 295 assertions, 0 failures, 0 errors
masa@masa ~/work/rpdf2txt $ unset RUBYOPT
masa@masa ~/work/rpdf2txt $ ruby1.9 -I lib test/suite.rb 
test/suite.rb:26: warning: variable $KCODE is no longer effective; ignored
/home/masa/work/rpdf2txt/test/test_pdf_object.rb:26: warning: variable $KCODE is no longer effective; ignored
/home/masa/work/rpdf2txt/test/test_pdf_parser.rb:28: warning: variable $KCODE is no longer effective; ignored
Loaded suite test/suite
Started
......................'invalid literal/lengths set' when filtering with /FlateDecode
.........................................................
..........unknown encoding 370 0 R
.............................................

Finished in 9.454758079 seconds.

134 tests, 295 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Resume set up ramaze oddb.org

Error

masa@masa ~/ywesee/ramaze.ch.oddb.org $ ruby1.9 start.rb 
/home/masa/ywesee/ramaze.ch.oddb.org/model/init.rb:3:in `require': no such file to load -- oddb/persistence/odba (LoadError)
        from /home/masa/ywesee/ramaze.ch.oddb.org/model/init.rb:3:in `<top (required)>'
        from /home/masa/ywesee/ramaze.ch.oddb.org/app.rb:32:in `require'
        from /home/masa/ywesee/ramaze.ch.oddb.org/app.rb:32:in `<top (required)>'
        from start.rb:7:in `require'
        from start.rb:7:in `<main>'

Experiment

masa@masa ~/ywesee/ramaze.ch.oddb.org $ ruby1.9 -I ../oddb/lib;../odba start.rb

Note

  • It looks running without error
  • But how can I access to it?

Next

  • Read codes

Download database (ch_oddb_org) data from online

Restore it

masa@masa ~/ywesee $ sudo -u postgres createdb -E UTF8 -T template0 ch_oddb_org
masa@masa ~/ywesee $ zcat postgresql_database-ch_oddb_org-backup_20110120.gz | psql -U postgres ch_oddb_org

Update etc/oddb.yml

---
db_name: ch_oddb_org
admins:
 - mhatakeyama@ywesee.com
debug_recipients:
 - mhatakeyama@ywesee.com
remote_databases: []
#credentials: 
# whocc: 
#  username: mhatakeyama@ywesee.com
#  password: xxx
server_url: 'druby://localhost:12000'
run_updater: false
run_exporter: false
query_limit: 5
query_limit_phase: 300
log_level: DEBUG
dojo_debug: true
#paypal_server: www.paypal.com
#paypal_receiver: mhatakeyama@ywesee.com
mail_invoice_from: '"masa" <mhatakeyama@ywesee.com>'
mail_invoice_smtp: mhatakeyama@ywesee.com
http_server: http://oddb.masa.org/
smtp_server: smtp.gmail.com

Set a virtual host

/etc/apache2/vhosts.d/07_ch.oddb.org.conf

<VirtualHost *:80>
ServerName ramaze.masa.ch.oddb.org

ServerAdmin mhatakeyama@ywesee.com

DefaultType text/html

ProxyPreserveHost On

# Configuration possibility 1 of 2:
# The entire domainname, from the root (/), is served by Ramaze
# Ramaze should be running at the defined host (192.168.1.100 in this example)
# and on the specified port (8000 in this example)
# Note the trailing slash after the port.
ProxyPass        / http://localhost:7000/
ProxyPassReverse / http://localhost:7000/
# End Configuration possibility 1 of 2.
</VirtualHost>

Restart apache

masa@masa /etc/apache2/vhosts.d $ sudo /etc/init.d/apache2 restart
* apache2 has detected an error in your setup:
Syntax error on line 11 of /etc/apache2/vhosts.d/07_ch.oddb.org.conf:
Invalid command 'ProxyPreserveHost', perhaps misspelled or defined by a module not included in the server configuration
* ERROR: apache2 failed to start

Error

masa@masa ~/ywesee/ramaze.ch.oddb.org $ ruby1.9 -I ../oddb/lib:../odba/lib ./start.rb 
/home/masa/ywesee/odba/lib/odba/storage.rb:6:in `require': no such file to load -- dbi (LoadError)
        from /home/masa/ywesee/odba/lib/odba/storage.rb:6:in `<top (required)>'
        from /home/masa/ywesee/odba/lib/odba.rb:61:in `require'
        from /home/masa/ywesee/odba/lib/odba.rb:61:in `<top (required)>'
        from /home/masa/ywesee/oddb/lib/oddb/persistence/odba.rb:5:in `require'
        from /home/masa/ywesee/oddb/lib/oddb/persistence/odba.rb:5:in `<top (required)>'
        from /home/masa/ywesee/ramaze.ch.oddb.org/model/init.rb:3:in `require'
        from /home/masa/ywesee/ramaze.ch.oddb.org/model/init.rb:3:in `<top (required)>'
        from /home/masa/ywesee/ramaze.ch.oddb.org/app.rb:32:in `require'
        from /home/masa/ywesee/ramaze.ch.oddb.org/app.rb:32:in `<top (required)>'
        from ./start.rb:7:in `require'
        from ./start.rb:7:in `<main>'

Install pg, dbd-pg, facets

masa@masa ~/ywesee/ramaze.ch.oddb.org $ sudo ruby1.9 /usr/bin/gem install pg -v=0.9.0
Building native extensions.  This could take a while...
Successfully installed pg-0.9.0
1 gem installed
Installing ri documentation for pg-0.9.0...
Installing RDoc documentation for pg-0.9.0...

masa@masa ~/ywesee/ramaze.ch.oddb.org $ sudo ruby1.9 /usr/bin/gem install dbd-pg
Successfully installed deprecated-2.0.1
Successfully installed dbi-0.4.5
Successfully installed dbd-pg-0.3.9
3 gems installed
Installing ri documentation for deprecated-2.0.1...
Installing ri documentation for dbi-0.4.5...
Installing ri documentation for dbd-pg-0.3.9...
Installing RDoc documentation for deprecated-2.0.1...
Installing RDoc documentation for dbi-0.4.5...
Installing RDoc documentation for dbd-pg-0.3.9...

Error

masa@masa ~/ywesee/ramaze.ch.oddb.org $ ruby1.9 -I ../oddb/lib:../odba/lib ./start.rb 
ERROR:  relation "object" already exists

ERROR:  relation "prefetchable_index" already exists

ERROR:  relation "extent_index" already exists

ERROR:  relation "object_connection" already exists

ERROR:  relation "target_id_index" already exists

ERROR:  relation "collection" already exists

/usr/lib64/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/columninfo.rb:49:in `[]=': can't add a new key into hash during iteration (RuntimeError)
        from /usr/lib64/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/columninfo.rb:49:in `block in initialize'
        from /usr/lib64/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/columninfo.rb:42:in `each_key'
        from /usr/lib64/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/columninfo.rb:42:in `initialize'
        from /usr/lib64/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/handles/database.rb:161:in `new'
        from /usr/lib64/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/handles/database.rb:161:in `block in columns'
        from /usr/lib64/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/handles/database.rb:161:in `collect'
        from /usr/lib64/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/handles/database.rb:161:in `columns'
        from /home/masa/ywesee/odba/lib/odba/connection_pool.rb:36:in `block in method_missing'
        from /home/masa/ywesee/odba/lib/odba/connection_pool.rb:26:in `next_connection'
        from /home/masa/ywesee/odba/lib/odba/connection_pool.rb:35:in `method_missing'
        from /home/masa/ywesee/odba/lib/odba/storage.rb:525:in `setup'
        from /home/masa/ywesee/odba/lib/odba/cache.rb:433:in `setup'
        from /home/masa/ywesee/oddb/lib/oddb/persistence/odba.rb:35:in `<module:ODDB>'
        from /home/masa/ywesee/oddb/lib/oddb/persistence/odba.rb:28:in `<top (required)>'
        from /home/masa/ywesee/ramaze.ch.oddb.org/model/init.rb:3:in `require'
        from /home/masa/ywesee/ramaze.ch.oddb.org/model/init.rb:3:in `<top (required)>'
        from /home/masa/ywesee/ramaze.ch.oddb.org/app.rb:32:in `require'
        from /home/masa/ywesee/ramaze.ch.oddb.org/app.rb:32:in `<top (required)>'
        from ./start.rb:7:in `require'
        from ./start.rb:7:in `<main>'

test.rb

h = {'1' => 1, '2' => 2, '3' => 3}
p h
h.each_key do |k|
  p k
  if k == '3'
    h['4'] = 4
  end
end
p h

Result

Ruby 1.8

masa@masa ~/work $ ruby18 test.rb 
{"1"=>1, "2"=>2, "3"=>3}
"1"
"2"
"3"
"4"
{"1"=>1, "2"=>2, "3"=>3, "4"=>4}

Ruby 1.9

masa@masa ~/work $ ruby1.9 -v
ruby 1.9.2dev (2010-07-11 revision 28618) [x86_64-linux]

masa@masa ~/work $ ruby1.9 test.rb 
{"1"=>1, "2"=>2, "3"=>3}
"1"
"2"
"3"
test.rb:7:in `[]=': can't add a new key into hash during iteration (RuntimeError)
        from test.rb:7:in `block in <main>'
        from test.rb:4:in `each_key'
        from test.rb:4:in `<main>'

Note (IMPORTANT)

 * This is the feature of Ruby 1.9.2, not Ruby 1.9.1
 * Namely, we cannot change Hash in its iteration in Ruby 1.9.2 (but Array can do)
 * (In my opinion, it makes Ruby less flexible)

It works on Ruby 1.9.1

$ ruby1.9 -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [x86_64-linux]

$ ruby1.9 test.rb 
{"a"=>1, "b"=>2, "c"=>3}
"a"
"b"
"c"
"4"
{"a"=>1, "b"=>2, "c"=>3, "4"=>4}

test.rb

a = [1,2,3]
p a
a.each do |x|
  p x
  if x==3
    a << 4
  end
end
p a

Result

masa@masa ~/work $ ruby1.9 test.rb 
[1, 2, 3]
1
2
3
4
[1, 2, 3, 4]

Refer to

Wed Feb 17 01:16:12 2010  Yusuke Endoh  <mame@tsg.ne.jp>

	* hash.c (hash_update): always raise an exception when adding a new
	  key during iteration.  Traditionally, an exception was raised only
	  when rehash occurs, but it may lead to difficult bug to reproduce.
	  [ruby-core:23614]

Experiment

/usr/lib64/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/columninfo.rb

        def initialize(hash=nil)
            @hash = hash.dup rescue nil
            @hash ||= Hash.new

            # coerce all strings to symbols
            hash_tmp = {}
            @hash.each_key do |x|
                if x.kind_of? String
                    sym = x.to_sym
                    if @hash.has_key? sym
                        raise ::TypeError,
                            "#{self.class.name} may construct from a hash keyed with strings or symbols, but not both"
                    end
                    #@hash[sym] = @hash[x]
                    hash_tmp[sym] = @hash[x]
                    @hash.delete(x)
                end
            end
            hash_tmp.each do |k,v|
              @hash[k] = v
            end

Result

masa@masa ~/ywesee/ramaze.ch.oddb.org $ ruby1.9 -I ../oddb/lib:../odba/lib ./start.rb 
ERROR:  relation "object" already exists

ERROR:  relation "prefetchable_index" already exists

ERROR:  relation "extent_index" already exists

ERROR:  relation "object_connection" already exists

ERROR:  relation "target_id_index" already exists

ERROR:  relation "collection" already exists

ERROR:  relation "target_id_oddb_drugs_sequence_fachinfo_indications_de" already exists

ERROR:  relation "oddb_business_company_name" already exists

/usr/lib64/ruby/gems/1.9.1/gems/dbd-pg-0.3.9/lib/dbd/pg/statement.rb:62:in `rescue in execute': ERROR:  relation "oddb_business_company_name" already exists (DBI::ProgrammingError)
        from /usr/lib64/ruby/gems/1.9.1/gems/dbd-pg-0.3.9/lib/dbd/pg/statement.rb:37:in `execute'
        from /usr/lib64/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/base_classes/database.rb:96:in `execute'
        from /usr/lib64/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/base_classes/database.rb:114:in `do'
        from /usr/lib64/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/handles/database.rb:106:in `do'
        from /home/masa/ywesee/odba/lib/odba/storage.rb:176:in `create_index'
        from /home/masa/ywesee/odba/lib/odba/index.rb:226:in `initialize'
        from /home/masa/ywesee/odba/lib/odba/cache.rb:148:in `new'
        from /home/masa/ywesee/odba/lib/odba/cache.rb:148:in `block in create_index'
        from /home/masa/ywesee/odba/lib/odba/storage.rb:558:in `call'
        from /home/masa/ywesee/odba/lib/odba/storage.rb:558:in `block in transaction'
        from /usr/lib64/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/handles/database.rb:209:in `transaction'
        from /home/masa/ywesee/odba/lib/odba/connection_pool.rb:36:in `block in method_missing'
        from /home/masa/ywesee/odba/lib/odba/connection_pool.rb:26:in `next_connection'
        from /home/masa/ywesee/odba/lib/odba/connection_pool.rb:35:in `method_missing'
        from /home/masa/ywesee/odba/lib/odba/storage.rb:554:in `transaction'
        from /home/masa/ywesee/odba/lib/odba/cache.rb:520:in `transaction'
        from /home/masa/ywesee/odba/lib/odba/cache.rb:140:in `create_index'
        from /home/masa/ywesee/odba/lib/odba/cache.rb:131:in `block in create_deferred_indices'
        from /home/masa/ywesee/odba/lib/odba/cache.rb:125:in `each'
        from /home/masa/ywesee/odba/lib/odba/cache.rb:125:in `create_deferred_indices'
        from /home/masa/ywesee/odba/lib/odba/cache.rb:437:in `setup'
        from /home/masa/ywesee/oddb/lib/oddb/persistence/odba.rb:35:in `<module:ODDB>'
        from /home/masa/ywesee/oddb/lib/oddb/persistence/odba.rb:28:in `<top (required)>'
        from /home/masa/ywesee/ramaze.ch.oddb.org/model/init.rb:3:in `require'
        from /home/masa/ywesee/ramaze.ch.oddb.org/model/init.rb:3:in `<top (required)>'
        from /home/masa/ywesee/ramaze.ch.oddb.org/app.rb:32:in `require'
        from /home/masa/ywesee/ramaze.ch.oddb.org/app.rb:32:in `<top (required)>'
        from ./start.rb:7:in `require'
        from ./start.rb:7:in `<main>'

Note

  • I can avoid that error, but another error comes
view · edit · sidebar · attach · print · history
Page last modified on January 19, 2012, at 02:27 PM