Pesquisar neste blogue

segunda-feira, 27 de julho de 2015

One of those things

After installing Odoo like said on the link (http://www.theopensourcerer.com/2014/09/how-to-install-openerp-odoo-8-on-ubuntu-server-14-04-lts/ ) i posted a few messages back.
I noticed a strange behaviour, , massive memory comsuption and cpu usage, on accounts-daemon on my ubuntu 15.04 instalation.
You can attach gdb to a running process by using --pid. So by using


1
sudo gdb --pid=597




I could debug the running process, and then i saw :


1
2
3
4
5
6
0x00007f4ae4dea1e1 in __GI__nss_files_parse_pwent (
    line=0x1f00606 ":x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin", 
    line@entry=0x1f00600 "nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin", result=result@entry=0x7f4ae50e7060 <resbuf>, data=data@entry=0x1f00600, 
    datalen=datalen@entry=1024, errnop=errnop@entry=0x7f4ae60747d0)
    at fgetpwent_r.c:34
34    fgetpwent_r.c: Ficheiro ou directoria inexistente (*).


(*) File or directory not existent..

Not good not good at all..

segunda-feira, 20 de julho de 2015

Pack Javascript and CSS

In some Java web related projects  i have worked the number of css and JavaScript files included in the jsp pages where sometime more than desired.At the time i came across Packtag which allows you to minify, combine and pack your resources into a single file therefore reducing the number of requests to your server which is always nice.

sexta-feira, 17 de julho de 2015

Playing with Odoo and Tesseract.

During these lasts days i have been reading things about Odoo and how it had improved since i last worked on it professionally and i came across  Basics-developing-simple-module-openerp a great resource for anyone wanting to start working on Odoo.
So work started on document_scanner, a plugin for Odoo, which uses Tesseract to import pictures and convert them to text .

 The entry point of a Odoo plugin is the __init__.py file and as my plugin is written on document_scanner.py my __init__.py file looks like


1
2
3
# -*- coding: utf-8 -*-

import document_scanner


Next lets take a look at the __openerp__.py file where you must include the dependencies, the description and your personal information which will be visible to the user when the plugin is installed. My file looks like:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{
    'name': 'Document Scanner',
    'version': '1.0',
    'category': 'Tools',
    'description': """
Module which uses OCR to treat image files in Odoo.
==============================================
    """,
    'author': 'Rui Caridade',
    'depends': ['base','document'],
    'data': ['document_scanner_view.xml'],
    'demo': [], 
    'installable': True,
    'auto_install': False
}


which visually translates to


On the __openerp__.py file if you notice there is a reference to a xml file "document_scanner_view.xml" which is where the look and feel of the plugin is defined.
On document_scanner the xml file looks like :


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

        <record id="document_scanner_wizard_view_form" model="ir.ui.view">
            <field name="name">document.scanner.wizard.form</field>
            <field name="model">document.scanner.wizard</field>
            <field name="arch" type="xml">
             <form string="Document Scanner">
                <group col="4">
                <field name="data"/>
                </group>
                <group col="4">
                    <field name="textoDaImagem"/>
                </group>
                    <button name="import_file" string="Import" type="object" />
                    <button icon="gtk-cancel" special="cancel" string="Cancel"/>
            </form>
            </field>
        </record>
        
     <record model="ir.actions.act_window" id="action_document_scanner_form">
        <field name="name">Document Scanner</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">document.scanner.wizard</field>
        <field name="view_type">form</field>
        <field name="view_mode">form</field>
        <field name="target">new</field>
    </record>
        
     <record id="action_dir_doc_scanner_view" model="ir.actions.act_window.view">
        <field name="view_mode">form</field>
        <field name="view_id" ref="document_scanner_wizard_view_form"/>
        <field name="act_window_id" ref="action_document_scanner_form"/>
    </record>

    <menuitem
        action="action_document_scanner_form"
        id="menu_document_scanner"
        parent="knowledge.menu_document_configuration"/>


    </data>
</openerp>


To better understand the file i recommend you read it from the menuitem till the top.

After that was done i needed to find a picture to test and i found Factura Vaca

The end result

 
The text is not quite right yet, still have to look into it. Still thinking on how i can improve this plugin. Any suggestions?



domingo, 5 de julho de 2015

Profiling with gcc and gprof

One of my passions in computing is virtualization.
A friend of mine some decades back showed me a Super Nintendo emulator on his Pentium MMX and i was hooked.
More professional uses of virtualization came with time however the gaming bug still sticks with me.
This weekend i took some time to play around a Sega Dreamcast emulator - Lxdream -  developed by Nathan Keynes as last time i tried to compile it i had some warnings caused by some linux includes which some undefs solved.


#undef REG_RAX 
#undef REG_RCX
#undef REG_RDX
#undef REG_RBX 
#undef REG_RSP
#undef REG_RBP
#undef REG_RSI
#undef REG_RDI
#undef REG_R8
#undef REG_R9
#undef REG_R10
#undef REG_R11
#undef REG_R12
#undef REG_R13
#undef REG_R14
#undef REG_R15



After that was fixed i tried to profile the code to see what could be improved. Fortunately Nathan already had the --enable-profile configure switch which sets `-pg' option when you run the compiler.
After that  the gprof command generates a nice informative file.


gprof src/lxdream gmon.out > analysis.txt


Below the top lines of the output file


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name    
 37.79      3.28     3.28                             cpu_print_registers
  9.10      4.07     0.79 123044895     0.00     0.00  arm_execute_instruction
  7.26      4.70     0.63                             ext_sdram_read_long
  6.68      5.28     0.58   109333     0.01     0.01  xlat_get_code
  2.77      5.52     0.24 18516563     0.00     0.00  sort_extract_triangles
  2.65      5.75     0.23                             ccn_prefetch
  2.19      5.94     0.19                             xlat_invalidate_long
  2.19      6.13     0.19  1531965     0.00     0.00  ta_commit_polygon
  2.07      6.31     0.18                             ext_sdram_write_word
  2.07      6.49     0.18                             ocram_page0_read_byte
  1.73      6.64     0.15                             xlat_flush_page
  1.50      6.77     0.13 150802470     0.00     0.00  arm_read_long
  1.50      6.90     0.13  6922797     0.00     0.00  ta_write_tile_entry
  1.50      7.03     0.13     1604     0.08     0.21  pvr2_scene_read
  1.38      7.15     0.12  4663896     0.00     0.00  sort_add_triangle
  1.27      7.26     0.11  3355889     0.00     0.00  pvr2_ta_process_block
  1.15      7.36     0.10    62003     0.00     0.00  audio_mix_samples
  1.04      7.45     0.09    62003     0.00     0.02  arm_run_slice
  1.04      7.54     0.09    21625     0.00     0.00  arm_restore_cpsr
  0.81      7.61     0.07                             ext_sdram_read_word
  0.81      7.68     0.07                             ext_sdram_write_long
  0.69      7.74     0.06  1238296     0.00     0.00  gl_render_tilelist
  0.63      7.80     0.06                             unmapped_prefetch



Maybe using OpenMP on that arm_execute_instruction is my next weekend computing fun.



sexta-feira, 3 de julho de 2015

Starting with Odoo - Part 1

Some years ago i worked professionaly with OpenERP in its version 5 and 6 for a small portuguese company called OpenSecure . Life takes you in different routes sometimes and i lost track of its development, which made Odoo a really pleasant surprise.
So in order to refresh my own knowledge of OpenErp and Python i decided to do a series of tutorials, or if you prefer progress reports,where we'll be making a simple app for Odoo , a document scanner using tesseract ocr ( Tesseract-ocr ).

First we need to install Odoo.
The most complete tutorial, really a great job people , can be found here - how-to-install-openerp-odoo-8-on-ubuntu-server -

We'll also need a python binding for tesseract -  pytesseract  - which means in Ubuntu or in your OS choice you may need also to install pip.

In the Part 2 i'll describe the anotomy of an OpenERP app and how to use   pytesseract to extract information from an image file.
If you can identify which kind of document it is the really fun part can begin :).


quarta-feira, 1 de julho de 2015

Before delving into Odoo i would like to share a project that has saved my life a couple of times - signtester .
If you need to sign (re-sign) several jar files take a look at it :)