27 Apr

Bio-metric data format standards

In developing software for handling bio-metric records, several standard are used for keeping the information.

These are the INCITS 378-2004 and ISO/IEC 19794-2:2005 (finger minutiae), INCITS 381-2004 and ISO/IEC 19794-4:2004 (finger image), and INCITS 385-2004 (face recognition format). The American National Standards were developed in the InterNational Committee for Information Technology Standards (INCITS(link is external)) Technical Committee M1 – Biometrics(link is external). The International standards were developed by the ISO/IEC JTC 1/SC 37(link is external) committee.

INCITS biometric standards have been adopted for use in various government programs including the Personal Identity Verification of Federal Employees and Contractors program developed by NIST. Their use is specified in NIST Special Publication 800-76-1.

25 Feb

Migrating from Python 2.7 to Python 3.4

Last year, we made a decision to migrate to python 3.4 in 2016. This was not an easy decision as all our code base in developed using python 2.7 and it has served us very well.

Yesterday, We took the big step. This has already been delayed and was overdue.

First the Python 3.4 has to be installed, using the same process as in previous blog. However, replacing 2.7 with 3.4

the virtualenv has to be recreated for python 3.4.

pyvenv <virtual env>

thunder lock: disabled (you can enable it with --thunder-lock)
 uwsgi socket 0 bound to UNIX address xhod.sock fd 3
 Python version: 2.7.10 (default, Sep 21 2015, 12:21:01) [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]
 Set PythonHome to /home/uobis/webapps/xhod/venv
 ImportError: No module named site

I had to recompile uwsgi for python 3.4

/usr/local/bin/pip2.7 uninstall uWSGI

/usr/local/bin/pip3.4 install uWSGI

*** Starting uWSGI 2.0.12 (64bit) on [Thu Feb 25 22:31:10 2016] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-16) on 25 February 2016 22:30:37
os: Linux-2.6.32-042stab108.8 #1 SMP Wed Jul 22 17:23:23 MSK 2015


01 Jun

uWSGI+NGINX on Linux (Centos 6)

Step 1 – Install NGINX

sudo yum install nginx

Step 2 – Add nginx to uobis group:

sudo usermod -a -G uobis nginx
sudo chmod g+x /home && chmod g+x /home/uobis && chmod g+x home/uobis/webapps/
sudo -u nginx stat /home/uobis/webapps/

cat >> kabbu.ini

module = wsgi
master = true
processes = 5
socket = kabbu.sock
chmod-socket = 660
vacuum = true

Step 3 – The uWSGI Emperor – multi-app deployment
exec uwsgi --emperor /etc/uwsgi/vassals/ --master --logto /var/log/uwsgi.log
Step 4 – Create a Upstart File

To make sure stuff is automatically run, here’s a configuration file that needs to be placed in /etc/init/uwsgi.conf

description "uWSGI Emperor"

start on runlevel [2345]
stop on runlevel [06]
exec uwsgi --emperor /etc/uwsgi/vassals/ --master --logto /var/log/uwsgi/emperor.log

Create the directories

mkdir /etc/uwsgi/vassals/

Then either reboot your system or:

sudo initctl start uwsgi
sudo initctl reload-configuration

To check if its started
initctl list

Check the system log file or the emperor.log if uwsgi is not started

30 May

Install Python on Linux (Centos)

Most installed python on Linux systems are outdated. While python 2.6 is quite good for a project, most are advised to use python 2.7 or 3.4, so the need to upgrade it.

However, for Centos 6, you are strongly advised to avoid upgrading or reinstalling the stock version as some important system programs (notable yum), uses it.
Removing the default version will break the dependent system programs, instead you should install your targeted version and make sure your files are linked to it.

Install Python 2.7

Run the following command to update the system applications:
$ sudo yum -y update

In order to get the necessary development tools, run the following:
$ sudo yum groupinstall -y development

# sudo yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel

Download, compile and install Python:

$ cd /opt
$ sudo wget --no-check-certificate https://www.python.org/ftp/python/2.7.X/Python-2.7.X.tar.xz
$ sudo tar xf Python-2.7.X.tar.xz
$ sudo cd Python-2.7.X
$ sudo ./configure --prefix=/usr/local
$ sudo make && make altinstall

List all python programs

$ ls -ltr /usr/bin/python*
$ ls -ltr /usr/local/bin/python*

Link Python 2.7 to the default python on local environment

$ ln -s /usr/local/bin/python2.7 /usr/local/bin/python

Install easy tools and pip

$ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
$ sudo /usr/local/bin/python2.7 ez_setup.py
$ sudo /usr/local/bin/easy_install-2.7 pip

Install virtualenv
$ pip2.7 install virtualenv


02 May

django and virtualenv on Aptana Studio

Create a folder for storing Virtualenv environments

C:Usersamachefe>mkdir env
C:Usersamachefe>cd env

Create a virtual environment VCMS by running the virtualenv command.
Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.
PS C:>
PS C:Usersamachefeenv>virtualenv vcms
New python executable in vcmsScriptspython.exe
Installing setuptools…………….done.
Installing pip……………….done.

In Microsoft Windows, before activating the virtual environment, ensure that the new environment is used by setting the Powershell execution policy
PS C:> Set-ExecutionPolicy RemoteSigned
PS C:> exit

Activate the virtualenv environment just created

PS C:Usersamachefeenv>vcmsScriptsactivate
(vcms) C:Usersamachefeenv>
(vcms) C:Usersamachefeenv>pip list

(vcms) C:Usersamachefeenv>pip show
ERROR: Please provide a package name or names.
(vcms) C:Usersamachefeenv>pip install django
Downloading/unpacking django
  Downloading Django-1.5.1.tar.gz (8.0MB): 8.0MB downloaded
   Running setup.py egg_info for package django

    warning: no previously-included files matching ‘__pycache__’ found under directory ‘*’
    warning: no previously-included files matching ‘*.py[co]’ found under directory ‘*’
Installing collected packages: django
  Running setup.py install for django

    warning: no previously-included files matching ‘__pycache__’ found under directory ‘*’
    warning: no previously-included files matching ‘*.py[co]’ found under directory ‘*’
Successfully installed django
Cleaning up…
Storing complete log in C:Usersamachefepippip.log

(vcms) C:Usersamachefeenv>

(vcms) C:Usersamachefeenv>pip list
Django (1.5.1)
(vcms) C:Usersamachefeenv>

Deactivate after installing

(vcms) C:Usersamachefeenv>deactivate

Setting up Aptana Studio

One of the best (and free) IDEs for is Aptana Studio. Aptana Studio is a complete environment that includes extensive capabilities to build Ruby and Rails, PHP, and Python applications, along with complete HTML, CSS and JavaScript editing. Aptana is based on Eclipse, and has one of the best python plugin, PyDev.
It has gives you two options for download. You can either install Aptana on top of your pre-existing Eclipse installation (Eclipse Plug-in Version), or install a standalone version of Eclipse with Aptana pre-configured. I prefer the stand alone version

To create a new Django project in Aptana, go to File->New -> Other. Select the PyDev folder, and finally, the PyDev Django Project option, and click next. Give the project a name.

Under the Interpreter, click to configure a new interpreter.

Hit New… Add Name for the interpreter, and specify a path to your newly made virtualenv. Click Ok

manually select the C:Python27Lib folder. Click OK

Click OK, to close the Python interpreter selector and return to the New Project box.

Select the Interpreter you just created in the last step, and Click Next. Complete the Requirement to create a project.
To test the project, Click the Aptana Studio RUN bottom

Aptana Studio Run button

Check if the project was successful from the browser

NB: You can also add a new Python Interpreter from Preferences > PyDev > Interpreter – Python settings.