Sunday 20 November 2016

AlisJK:ODKScan

Status : Draft

Linux

python


Ketika install, pastikan menggunakan python 2.7.9 jika menggunakan python > 2.7.9 sepertinya ketika  penulis menggunakan python 2.7.12 maka akan muncuk error seperti ini ketika menjalankan celery :

alisjk@openthinklabs002$:celery --version
Traceback (most recent call last):
  File "/usr/local/bin/celery", line 9, in <module>
    load_entry_point('celery==3.0.17', 'console_scripts', 'celery')()
  File "/usr/local/lib/python2.7/dist-packages/celery/__main__.py", line 12, in main
    maybe_patch_concurrency()
  File "/usr/local/lib/python2.7/dist-packages/celery/__main__.py", line 7, in maybe_patch_concurrency
    from celery.platforms import maybe_patch_concurrency
  File "/usr/local/lib/python2.7/dist-packages/celery/platforms.py", line 22, in <module>
    from kombu.utils.encoding import safe_str
  File "/usr/local/lib/python2.7/dist-packages/kombu/utils/__init__.py", line 17, in <module>
    from uuid import UUID, uuid4 as _uuid4, _uuid_generate_random
ImportError: cannot import name _uuid_generate_random

Untuk kompilasi python 2.7.9 di Ubuntu dapat membaca [1] atau jika menggunakan Ubuntu 16.04 64 bit, Anda bisa mengunduh .deb nya disini.

Install dengan perintah :

sudo dpkg -i python-2.7.9_2.7.9-1_amd64.deb 


Jika ingin uninstall, perintah :

sudo  dpkg -r python-2.7.9

Instalasi


ODKScan_Webapp berhasil diinstall dengan paket-paket berikut :
alisjk@openthinklabs:~$ pip list  --format=columns 
Package         Version 
--------------- --------
amqp            1.0.13  
anyjson         0.3.3   
billiard        2.7.3.34
celery          3.0.17  
cffi            1.9.1   
cryptography    1.7.2   
Django          1.5.1   
django-celery   3.0.17  
enum34          1.1.6   
idna            2.2     
image           1.5.5   
ipaddress       1.0.18  
kombu           2.5.16  
meld3           1.0.2   
MySQL-python    1.2.5   
nose            1.3.7   
olefile         0.44    
PIL             1.1.7   
pip             9.0.1   
pyasn1          0.2.2   
pycparser       2.17    
pyOpenSSL       16.2.0  
python-dateutil 1.5     
pytz            2016.10 
setuptools      33.1.1  
six             1.10.0  
spec            1.3.1   
supervisor      3.2.0   
textile         2.1.5   
vine            1.1.3   
virtualenv      15.1.0  
xlrd            0.8.0  

Untuk PIL 1.1.7 bisa didownload di : http://effbot.org/media/downloads/PIL-1.1.7.tar.gz

Dengan VirtualEnv


Lihat [3]

sudo pip install virtualenvwrapper
sudo nano ~/.bash_profile
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
source ~/.bash_profile
mkvirtualenv -p /opt/python279/bin/python scanadmin --no-site-packages
cd apps/scanadmin/ODKScan_webapp
workon scanadmin
pip install -r requirements.pip

Untuk uji coba, jalankan perintah ini di direktori scanadmin :

python manage.py runserver 8080

Jika muncul error seperti dibawah, 


Request Method:GET
Request URL:http://scanadmin.np:8080/admin/ODKScan_webapp/formimage/
Django Version:1.5.1
Exception Type:TemplateDoesNotExist
Exception Value:
admin/login.html
Exception Location:/home/wildan/.virtualenvs/scanadmin/lib/python2.7/site-packages/django/template/loader.py in find_template, line 139
Python Executable:/home/wildan/.virtualenvs/scanadmin/bin/python
Python Version:2.7.9

Install ulang semua requirements dengan perintah :

pip install -r requirements.pip --ignore-installed --force-reinstall --upgrade --no-cache-dir

lalu coba lagi :

python manage.py runserver 8080

Apache + mod_wsgi

Berikut adalah konfigurasi virtualhost yang digunakan :



ODKScanCore 


Untuk kompilasi ODKScanCore dapat membaca [8]

Mac OS X

Nginx + Django + virtualenv 

cd scanadmin
pip install virtualenv
virtualenv venv
source venv/bin/activate 
sudo pip install -r requirements.txt

Ketika menjalankan perinta ini error :

    building '_mysql' extension
    creating build/temp.macosx-10.14-x86_64-2.7
    clang -fno-strict-aliasing -fno-common -dynamic -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mysql/8.0.15/include/mysql -I/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.14-x86_64-2.7/_mysql.o
    _mysql.c:44:10: fatal error: 'my_config.h' file not found
    #include "my_config.h"
             ^~~~~~~~~~~~~
    1 error generated.
    error: command 'clang' failed with exit status 1

Solusi : 

brew install mysql-connector-c
brew unlink mysql && brew link mysql
pip install -r ../../requirements.txt --global-option=build_ext --global-option="-I/usr/local/Cellar/mysql-connector-c/6.1.11/include" --global-option="-L/usr/local/opt/openssl/lib"
mkdir /usr/local/etc/uwsgi/vassals
ln -s /path/to/scanadmin/scanadmin_uwsgi.ini /usr/local/etc/uwsgi/vassals/
supervisorctl -c supervisord.conf reload
sudo supervisorctl
supervisor>start scanadmin

Referensi

  1. Installation of Python 2.7.9 in Ubuntu, http://python.openthinklabs.com/2017/06/pyside-instalasi.html
  2. ODKScan_webapp, https://github.com/OpenThink-Labs/ODKScan_webapp
  3. Deploy Django on Apache with Virtualenv and mod_wsgi, http://thecodeship.com/deployment/deploy-django-apache-virtualenv-and-mod_wsgi/
  4. Setting up Django and your web server with uWSGI and nginx, http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html
  5. Deploy Django Applications Using uWSGI and Nginx on Ubuntu 14.04, https://www.linode.com/docs/websites/nginx/deploy-django-applications-using-uwsgi-and-nginx-on-ubuntu-14-04
  6. Wiring uWSGI to work with Django and nginx on Ubuntu 16.04, http://serverfault.com/questions/775965/wiring-uwsgi-to-work-with-django-and-nginx-on-ubuntu-16-04
  7. No module named _sysconfigdata_nd, http://stackoverflow.com/questions/15608236/eclipse-and-google-app-engine-importerror-no-module-named-sysconfigdata-nd-u
  8. Open Data Kit : ODK Scan, http://software.openthinklabs.com/2017/05/open-data-kit-odk-scan.html

Saturday 12 November 2016

AlisJK:SmartScan

AlisJK:SmartScan merupakan utilitas pelengkap aplikasi Analisis Lembar Jawaban Komputer (AlisJK), yang memiliki fungsi :

  1. Mempermudah proses scanning LJK
  2. Kita bisa mengetahui gambar LJK discan oleh siapa
  3. Hasil scan otomatis disimpan di server yang nantinya secara otomatis akan dibaca oleh SmartOMR (ODKScan)
  4. Parameter-parameter default agar gambar yang dihasilkan lebih optimal untuk diproses kemudian oleh ODKScan dan tidak terjadi kesalahan pemilihan parameter oleh user. Parameter-parameter yang diset secara default diantaranya : 
    • Format gambar yang dihasilkan adalah jpg
    • Resolusi : 200 dpi
    • Mode : Color (RGB)
    • Feeder : Diaktifkan
    • Duplex Mode : Tidak Aktif
    • Brightness : 0f
    • Contrast : 0f
Ketika scan, nama file langsung dimasukkan ke database, gunanya untuk rekapitulasi dan melihat progress pembacaan LJK oleh AlisJK:ScanAdmin.