Friday, March 31, 2017

My first sms project using TWILIO , PYTHON and DOCKER

I just found out this cool app called twilio and I really interested how it works. My main objective is to create a mass sms sending app but its too far at this point.

First, I found this youtube from cleverprogramming website. https://www.youtube.com/watch?v=uzBRycRYsqw. The tutorial is very straight forward. I can follow his steps but I want something different in my setup. I want to use docker instead installing in my development pc which I'm working in the office now. Hopefully no ones knows what I'm doing. haha

But anyway, so first I'm struggling how to mount the volume from my python image. So this is what I did.

1. run docker pull python
this will pull the latest images which i think python 3.6

2. create a dockerfile
FROM python
RUN pip install twilio
VOLUME ["/mnt/python_file"]

from script above, I creating a python base image and install twilio app and specify the volume. Isn't that easy. But the hardest part, is that I don't know if its working exactly what I wanted.

3. run docker build -t python-twilio

i have already my custom image, next will run this to create a container.

4. run docker run -v /c/Users/DEFAULT.DEFAULT-PC/volumes:/mnt/python_file python-twilio python /mnt/python_file/send_sms.py

previously, i didn't add '/mnt/python_files/' from send_sms.py which giving me error that the file is not found. So that's it, i received the sms message to my phone, Eureka!

btw, I have so much to improve my code. we will see next time to achieve my goal to build an app. Viola!



UPDATED:
The new command below is changing the volume from c: drive to d:.
d_drive name is the same which I configure in the Oracle VM virtualbox.

ex1:
docker run -v /d_drive/Lynard/development/personal/twilio_tutorial:/mnt/python_file twilio1 python /mnt/python_file/send_sms.py

ex2:
docker run -v /d_drive/Lynard/development/personal/twilio_tutorial:/mnt/codes ls/twilio python /mnt/codes/send_sms.py

So now, I can do and save my code in my drive D: isn't that great! Eureka!!!!

Thursday, March 30, 2017

Install Odoo 9 and Postgresql 9.3 inside docker container

Currently I'm working on a Odoo application where we installed our development environment in the Ubuntu/VMware. Apparently, I also like to know how to install the same setup using docker container and I tell you its not easy but luckily after few trial, here's my command that works perfectly.


1. Install postgres 9.3 with username = admin and password = admin. Port is default 5432 and the name of the container is postgres9.3, its makes sense. I'm not sure what is the --restart=always attribute but we can just leave that as is it.

docker run -d -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=admin --name postgres9.3 -p 5432:5432 --restart=always postgres:9.3


2. Install Odoo 9 with default port 8069. The container name is odoo9 and its link with the postgres installed as above. That's it, very simple but it took me a while to figure it out. I'm still not an expert devops.

docker run -p 8069:8069 --name odoo9 --link postgres9.3:db -t odoo:9


mount custom addons
docker run -v /dev_path/svn/repo2/trunk:/mnt/extra-addons -p 8069:8069 --name vbroker --link postgres9.3:db -t ls/odoo9



Updated:
Everything works fine on the above setup however when I launch my code , it shows warning that need to install pika module. So I decided to get the Dockerfile from official odoo 9 installation from github. https://hub.docker.com/_/odoo/



build again using below command
$docker build -t <name> .

Eureka!

Wednesday, March 29, 2017

How to increase the disk size of Linux (Ubuntu) in VMware

It took me few days how to configure to increase the disk size space of Ubuntu in VMware. Previously I only have 10gb which I use in my development but as everyday goes by more and more application installed in the system which gives me warning that my disk space has only 300mb left.

After many resources that I research in google I finally found the right guide/tutorial how to increase the disk space. This is the website https://www.rootusers.com/use-gparted-to-increase-disk-size-of-a-linux-native-partition/ and stated perfectly what I want.

I have added 10gb more and I can continue to code happily ever after without any warning of disk space. Eureka!



Odoo 9 Installation guideline

First thing of advice, when running odoo in vmware where ubuntu is installed as operating system. Configure the harddisk around 40gb and the memory at 3gb to get most optimize one. 

#apply any patches and make sure your Ubuntu server is accessing the Internet

sudo apt-get update
sudo apt-get dist-upgrade

#reboot your server

sudo reboot

#install postgres

sudo apt-get install postgresql

#change over to the postgresql to set permissions on our development user

sudo su - postgres
createuser --createdb --username postgres --no-createrole --pwprompt devlynard

#python dependencies

sudo apt-get install python-cups python-dateutil python-decorator python-docutils python-feedparser
sudo apt-get install python-gdata python-geoip python-gevent python-imaging python-jinja2 python-ldap
sudo apt-get install python-libxslt1 python-lxml python-mako python-mock python-openid python-passlib
sudo apt-get install python-psutil python-psycopg2 python-pybabel python-pychart python-pydot python-pyparsing
sudo apt-get install python-pypdf python-reportlab python-requests python-simplejson python-tz python-unicodecsv
sudo apt-get install python-unittest2 python-vatnumber python-vobject
sudo apt-get install python-werkzeug python-xlwt python-yaml wkhtmltopdf
sudo apt-get install python-pip python-dev libevent-dev gcc libxml2-dev libxslt-dev node-less geoip-database-contrib
sudo apt-get install python-pip git-core
sudo pip install pika

#install git

sudo apt-get install git

#download odoo framework

git clone https://www.github.com/odoo/odoo --depth 1 --branch 9.0 --single-branch .

#Linux file sharing services compatible with Microsoft

sudo apt-get install samba samba-common-bin
sudo smbpasswd -a odoo
sudo nano /etc/samba/smb.conf

[homes]
comment = Home Directories
browseable = yes
read only = no
create mask = 0640
directory mask = 0750

sudo /etc/init.d/smbd restart


#Install subversion on Ubuntu

sudo apt-get install subversion
svn co --username <username> svn://172.18.6.230/repo2
sudo dpkg -l|grep subversion
svn –version
svn update

#to install rabbitvcs

sudo add-apt-repository ppa:rabbitvcs/ppa
sudo apt-get update
sudo apt-get install rabbitvcs-nautilus3



#installing PIP And PyPDF2 To Read PDF File With Python On Ubuntu Linux

sudo apt-get update
sudo apt-get -y install python-pip
pip --help
sudo pip install PyPDF2



#install pycharm in ubuntu

Download Pycharm
https://www.jetbrains.com/pycharm/download/#section=linux

Copy the pycharm-*.tar.gz to an empty directory
(make sure you have rw permissions for that directory)

Unpack the pycharm-*.tar.gz using the following command:

tar xfz pycharm-*.tar.gz

Remove the pycharm-*.tar.gz to save disk space (optional)
Run pycharm.sh from the bin subdirectory

NOTE: PyCharm on Linux doesn't need special installation or running any installation script. It runs out of the pycharm-*.tar.gz




#additional libraries

sudo apt-get install python-pip

sudo apt-get install python-yaml
pip install pytz
sudo pip install python-dateutil
sudo pip install tzlocal   


free online comma separating tool

https://delim.co/#