Tag Archives: PyFacebook

First version of WeTwoo now “On Air”

WeTwoo on air

WeTwoo on Air

With several months delayed, we are launched a first beta version of WeTwoo.com (We-Two-o) which for the moment has few features available which are day to day improving …  May be you are asking, What hell is wetwoo?. WeTwoo is a facebook application which attempt to be a place to know information about  you friends that have some type of relationship. The current functionality are:

  • Know the status of relationship of all your friends. For this, you can see a pie-chat which show the distribution of relationship of your friends.
  • Show a List, in one place, the friends that have some type of relationship that is showed on facebook.
  • Make comments about the relation of your friends. Click on the name of you friend on the “Friends in Couple” page and the comment will appear on the wall of your friend.
  • Make comments about the application and these will be show on the wall of your friends.
  • Invite to friend to join wetwoo. In this way, the list of friends listed on “Friends in couple” will grow because only is show the couple that are accepted the application.
  • Available on English and Spanish (Español)

Other features that we hope add:

  • Save and help to remember the anniversary of couple to friends.
  • Save the comments that are done for some couples.
  • Suggest possibles couples as “Couple-friends”.

The application is developed using Ubuntu, Python, Django, Apache, Lighttpd, and PostgreSQL with the help of some libraries as MatPlotLib for graphs and PyFacebook which allow access to Facebook API.
I hope write more on the next months about technical issues to share this process with you.

Before end, I would like to invite to join to the site and make any comments or suggestion about it and help to spread with your contacts.

Best regards,

Álvaro


WeTwoo development

This post will show the steps necessary to FINISH my thesis and will help me to reproduce the steps in case that some issue make me have start again. Why English. just for practice :)

  • Install Ubuntu 8.10
  • Configure sound (to work in nice place :P). See my other post related
  • Install my printer driver (see my other post related)
  • Install RapidSVN. RapidSVN is gui client for Subversion. In windows I use TortoiseSVN
  • Add repository to RapidSVN
  • Install PostgerSQL. Synaptic Package Manager should show:

PostgreSQL Installation

    postgresql (version 8.3.5-0ubuntu8.10) will be installed
    postgresql-8.3 (version 8.3.5-0ubuntu8.10) will be installed
    postgresql-client-8.3 (version 8.3.5-0ubuntu8.10) will be installed
    postgresql-client-common (version 90) will be installed
    postgresql-common (version 90) will be installed

After I've installed postgresql, I followed the steps that Dav show in they blog (http://hocuspokus.net/2008/05/13/install-postgresql-on-ubuntu-804/) Install PostgreSQL on Ubuntu 8

Account for postgres that I made is postgres with “mitesis” as password

Install Subversion client to be used in command line
alvaro@KonunantuLnx:~$ sudo apt-get install subversion

Install Django

Read the post to install Django:

http://realm3.com/articles/installing_django_from_source_on_ubuntu_8.10

Django was installed in: /usr/local/lib/django-1.0.2/django/

Install PostgreSQL

Install pyscopq2, Python module for PostgreSql using Synaptic Package Manager

python-egenix-mxdatetime (version 3.1.0-1) will be installed
python-egenix-mxtools (version 3.1.0-1) will be installed
python-psycopg2 (version 2.0.8-0ubuntu1) will be installed

Instal MySQL Server for Mantis.

sudo apt-get install mysql-server

Installation  of Mantis. using Synaptic Package Manager you can install it. Mantis is a :

apache2-mpm-worker will be removed
apache2-mpm-prefork (version 2.2.9-7ubuntu3) will be installed
dbconfig-common (version 1.8.39) will be installed
libapache2-mod-php5 (version 5.2.6-2ubuntu4) will be installed
libdbd-mysql-perl (version 4.007-1build1) will be installed
libdbi-perl (version 1.605-1) will be installed
libnet-daemon-perl (version 0.38-1.1) will be installed
libphp-adodb (version 5.04a-1) will be installed
libphp-phpmailer (version 1.73-6) will be installed
libplrpc-perl (version 0.2017-1.1) will be installed
mantis (version 1.1.2+dfsg-8) will be installed
mysql-client (version 5.0.67-0ubuntu6) will be installed
mysql-client-5.0 (version 5.0.67-0ubuntu6) will be installed
php5 (version 5.2.6-2ubuntu4) will be installed
php5-common (version 5.2.6-2ubuntu4) will be installed
php5-mysql (version 5.2.6-2ubuntu4) will be installed

Install Notes:

libphp-adodb is no longer installed in /usr/share/adodb. New installation path is now /usr/share/php/adodb.

Please update your php.ini file. Maybe you must also change your web-server configuraton.

Message 2:

By default, the mantis package creates an administrator account. The password for this account is ‘root’.

It is highly recommended to change this password immediately after installation is complete.

Forget a mail server, I’ll install:

python-openssl (version 0.7-2) will be installed
python-pam (version 0.4.2-12ubuntu2) will be installed
python-pyopenssl (version 0.7-2) will be installed
python-serial (version 2.3-1) will be installed
python-twisted-bin (version 8.1.0-4) will be installed
python-twisted-core (version 8.1.0-4) will be installed
python-twisted-mail (version 8.1.0-2) will be installed
python-twisted-names (version 8.1.0-1) will be installed
python-zopeinterface (version 3.3.1-7build1) will be installed

I got this wrriting (SMTP) in SPM (Sinaptic Package Manager)

Install Postfix:

alvaro@KonunantuLnx:~$ sudo apt-get install postfix
..other messages in console removed for post..
Postfix is now set up with a default configuration.  If you need to make
changes, edit
/etc/postfix/main.cf (and others) as needed.  To view Postfix configuration
values, see postconf(1).
After modifying main.cf, be sure to run '/etc/init.d/postfix reload'.
Running newaliases

  • Stopping Postfix Mail Transport Agent postfix                         [ OK ]
  • Starting Postfix Mail Transport Agent postfix                         [ OK ]

Processing triggers for libc6 …
ldconfig deferred processing now taking place
alvaro@KonunantuLnx:~$

After Install postfix, I decide work with a external SMTP server because mails sent from my machine were refused in target server, like Gmail.com and Yahoo.es.

The file edited was: config_defaults_inc.php

and the lines:

$g_smtp_host            = ‘mail.aebcagenda.com’;

# These options allow you to use SMTP Authentication when you use a remote
# SMTP host with phpMailer.  If smtp_username is not ” then the username
# and password will be used when logging in to the SMTP server.
$g_smtp_username = ‘mantis+aebcagenda.com’;
$g_smtp_password = ‘************’;

Once configurated SMTP Server, Mantis doesn’t work correctly with mail too, so I modified the file

class.phpmailer.php and I added

define( 'PHPMAILER_PATH', 'libphp-phpmailer' . DIRECTORY_SEPARATOR );

into line 20 and after restart the apache, Mantis was able to send mail to gmail :) without problems.
Note: I found a post in http://www.mantisbt.org/forums/viewtopic.php?f=3&t=3223 regarding to this issue that help me.

Steps with Django.. for final app

alvaro@KonunantuLnx:~/tesis/Code/Django/pjWeTwoo$ python manage.py syncdb
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site

You just installed Django’s auth system, which means you don’t have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (Leave blank to use ‘alvaro’):
E-mail address: alvarobrange@gmail.com
Password:
Password (again):
Superuser created successfully.
Installing index for auth.Permission model
Installing index for auth.Message model
alvaro@KonunantuLnx:~/tesis/Code/Django/pjWeTwoo$

PostgreSQL – Contrib and how to use dblink function

dblink function allow us acess to remote postgresql database. In order to use it, you must:

  • Install PostgreSQL contrib package, which provides several additional features for the PostgreSQL database. contrib often serves as a testbed for

features before they are adopted into PostgreSQL proper.

  • Execute dblink sql in pgadmin. dblink.sql is located in /usr/share/postgresql/8.3/contrib in Ubuntu:

For details see:

dblink

http://www.experts-exchange.com/Databases/PostgreSQL/Q_21902314.html

I tested with the follow code:

CREATE TABLE d_user_temp AS SELECT first_name
FROM dblink('hostaddr=192.168.2.3 dbname=wetwoo user=miuser password=mipassword', 'SELECT first_name FROM wetwoo_person')
AS f(first_name character varying(200))

IPython was installed. Recommended by Django. Details about Ipython http://ipython.scipy.org/moin/

Some django utils commands and paths:

Check: http://docs.djangoproject.com/en/dev/ref/django-admin/

Reset database:

alvaro@KonunantuLnx:~/tesis/Code/Django/pjWeTwoo$ python manage.py reset wetwoo

Show changes carried out to reset without do it.

alvaro@KonunantuLnx:~/tesis/Code/Django/pjWeTwoo$ python manage.py sqlreset wetwoo

To find out your system’s site-packages location, execute the following:
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

Paths
This folder has admin files of Django:
/usr/local/lib/django-1.0.2/django/contrib/admin/templates/admin

Media file of Django

/usr/local/lib/django-1.0.2/django/contrib/admin/media/

Django Evolution

Project Web Site: http://code.google.com/p/django-evolution/

This allow you update your model after initial syncdb. Usage:
Before we start making changes to “models.py“, we need to set up the
project to allow evolutions. To do this, we add “django_evolution“ to the
“settings.INSTALLED_APPS“ and run “./manage.py syncdb“. This sets up
the tables for tracking model changes::

$ ./manage.py syncdb
Creating table django_evolution
Installing baseline version for testproject.blogette
Loading 'initial_data' fixtures...
No fixtures found.

Now we can go into “models.py“ remove the “date_of_birth“ field.
After removing the field, “./manage.py syncdb“ will provide a warning
that changes have been detected::

$ ./manage.py syncdb
Project signature has changed - an evolution is required
Loading 'initial_data' fixtures...
No fixtures found.

Django links for documentation:

Queries: http://docs.djangoproject.com/en/dev/topics/db/queries/#topics-db-queries

Commands: http://docs.djangoproject.com/en/dev/ref/django-admin

Initial data for models: http://docs.djangoproject.com/en/dev/howto/initial-data/#providing-initial-sql-data

Model Meta Options: http://docs.djangoproject.com/en/dev/ref/models/options/#django.db.models.Options.unique_together

Fields: http://docs.djangoproject.com/en/dev/ref/models/fields/

Many to many relationships: http://www.djangoproject.com/documentation/models/many_to_many/

Settings in Django http://docs.djangoproject.com/en/dev/ref/settings/

Django with Apache.

Information: http://docs.djangoproject.com/en/dev/howto/deployment/modpython

In order to work with Apache, we needs install mod-python installed

libapache2-mod-python (version 3.3.1-3) will be installed
libapache2-mod-python-doc (version 3.3.1-3) will be installed

<Location "/mysite/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE pjWeTwoo.settings
PythonOption django.root /mysite
PythonDebug On
PythonPath "['/usr/lib/python2.5/site-packages','/home/alvaro/tesis/Code/Django/','/home/alvaro/tesis/Code/Django/pjWeTwoo'] + sys.path"
</Location>

Django with Apache and Lighttpd for server static files

http://www.inerciasensorial.com.br/2007/06/10/perils-of-software-development/lighttpd-with-apache/

Symbolinc link for admin folder.This allow let the original folder without change and update the django code from SVN without needs for update manually other folder.

alvaro@KonunantuLnx:/var/www$ sudo ln -s /usr/local/lib/django-1.0.2/django/contrib/admin/media media

Apache Config file was added to respository. To do it, I make a symbolic link:

alvaro@KonunantuLnx:/etc/apache2/sites-available$ sudo ln -s /home/alvaro/tesis/Code/Django/pjWeTwoo/Config_files/apache2/default default
alvaro@KonunantuLnx:/etc/apache2$ sudo ln -s /home/alvaro/tesis/Code/Django/pjWeTwoo/Config_files/apache2/httpd.conf httpd.conf
alvaro@KonunantuLnx:/etc/lighttpd$ sudo ln -s /home/alvaro/tesis/Code/Django/pjWeTwoo/Config_files/lighttpd/lighttpd.conf lighttpd.conf

Linux Commands:
  • List directory or files permissions. To change, use chmod or sudo chmod
alvaro@KonunantuLnx:/var/www/media$ ls -l
  • Know the process that are running and owner of it: alvaro@KonunantuLnx:/etc/lighttpd$ ps aux

Other web pages/links

http://www.freesoftwaremagazine.com/articles/users_in_ubuntu?page=0%2C0 show information about user and groups

Download PyFacebook:

alvaro@KonunantuLnx:~/tesis/Code/Django/pjWeTwoo/pyfacebook$ svn checkout http://pyfacebook.googlecode.com/svn/trunk/ pyfacebook-read-only
Install PyFacebook:

alvaro@KonunantuLnx:~/tesis/Code/Django/pjWeTwoo/pyfacebook$ sudo python setup.py install
[sudo] password for alvaro:
running install
running build
running build_py
running install_lib
creating /usr/lib/python2.5/site-packages/facebook
creating /usr/lib/python2.5/site-packages/facebook/djangofb
copying build/lib/facebook/djangofb/context_processors.py -> /usr/lib/python2.5/site-packages/facebook/djangofb
copying build/lib/facebook/djangofb/models.py -> /usr/lib/python2.5/site-packages/facebook/djangofb
copying build/lib/facebook/djangofb/__init__.py -> /usr/lib/python2.5/site-packages/facebook/djangofb
copying build/lib/facebook/wsgi.py -> /usr/lib/python2.5/site-packages/facebook
copying build/lib/facebook/__init__.py -> /usr/lib/python2.5/site-packages/facebook
byte-compiling /usr/lib/python2.5/site-packages/facebook/djangofb/context_processors.py to context_processors.pyc
byte-compiling /usr/lib/python2.5/site-packages/facebook/djangofb/models.py to models.pyc
byte-compiling /usr/lib/python2.5/site-packages/facebook/djangofb/__init__.py to __init__.pyc
byte-compiling /usr/lib/python2.5/site-packages/facebook/wsgi.py to wsgi.pyc
byte-compiling /usr/lib/python2.5/site-packages/facebook/__init__.py to __init__.pyc
running install_egg_info
Writing /usr/lib/python2.5/site-packages/pyfacebook-0.1.egg-info

For get example  for Django and Facebook, I followed the post of SHABDA which help me a lot :)

Change name to folder:

alvaro@KonunantuLnx:/var/www/media/img$ sudo rename -f pwd heart.jpg
Bareword “pwd” not allowed while “strict subs” in use at (eval 1) line 1.
alvaro@KonunantuLnx:/var/www/media/img$ sudo mv pwd heart.jpg

Install NumPy (performing a search into Synaptic Package Manger)

libblas3gf (version 1.2-1.6) will be installed
libgfortran3 (version 4.3.2-1ubuntu12) will be installed
liblapack3gf (version 3.1.1-0.4ubuntu1) will be installed
python-dbg (version 2.5.2-1ubuntu1) will be installed
python-numpy (version 1:1.1.1-1) will be installed
python-numpy-dbg (version 1:1.1.1-1) will be installed
python-numpy-doc (version 1:1.1.1-1) will be installed
python2.5-dbg (version 2.5.2-11.1ubuntu1) will be installed

Install matplotlib (Synaptic Package Manager)

dvipdfmx (version 1:20071115-1) will be installed
dvipng (version 1.11-1) will be installed
latex-beamer (version 3.07-1ubuntu1) will be installed
latex-xcolor (version 2.11-1) will be installed
libt1-5 (version 5.1.2-2) will be installed
lmodern (version 1.010x-5) will be installed
pgf (version 2.00-1) will be installed
prosper (version 1.00.4+cvs.2007.05.01-3) will be installed
python-dateutil (version 1.4-1ubuntu2) will be installed
python-excelerator (version 0.6.3a-3) will be installed
python-matplotlib (version 0.98.3-4ubuntu1) will be installed
python-matplotlib-data (version 0.98.3-4ubuntu1) will be installed
python-pyparsing (version 1.5.0-1) will be installed
python-tz (version 2008b-3ubuntu1) will be installed
tetex-bin (version 2007.dfsg.1-2) will be installed
tex-common (version 1.11) will be installed
texlive (version 2007.dfsg.1-2) will be installed
texlive-base (version 2007.dfsg.1-2) will be installed
texlive-base-bin (version 2007.dfsg.2-3ubuntu1) will be installed
texlive-base-bin-doc (version 2007.dfsg.2-3ubuntu1) will be installed
texlive-common (version 2007.dfsg.1-2) will be installed
texlive-doc-base (version 2007.dfsg.1-1) will be installed
texlive-fonts-recommended (version 2007.dfsg.1-2) will be installed
texlive-fonts-recommended-doc (version 2007.dfsg.1-2) will be installed
texlive-generic-recommended (version 2007.dfsg.1-2) will be installed
texlive-latex-base (version 2007.dfsg.1-2) will be installed
texlive-latex-base-doc (version 2007.dfsg.1-2) will be installed
texlive-latex-recommended (version 2007.dfsg.1-2) will be installed
texlive-latex-recommended-doc (version 2007.dfsg.1-2) will be installed
texlive-pstricks (version 2007.dfsg.2-1ubuntu1) will be installed
texlive-pstricks-doc (version 2007.dfsg.2-1ubuntu1) will be installed
tipa (version 2:1.3-12) will be installed

Testing charts/graphs with matplotlib

I followed the post of Christiano Anderson about Django and MatPlotLib and I got some issue, but I fix. Here show how:

Error message in web page:
Failed to create /var/www/media/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data
Solution:
Then, I added this lines:
def chart(request):
import os
import dbus
os.environ['HOME'] = ‘/var/www/media’

Linl to ussful standart about files:

http://www.ietf.org/rfc/rfc2183.txt

Aptana Installation on Ubuntu 8.10

I followed instruction that  Andrew Bleakley states on his blog

Django Internationalization

This coomands help to translate and compille the language files:

alvaro@KonunantuLnx:~/tesis/Code/Django/pjWeTwoo$ django-admin.py makemessages -l es
processing language es
alvaro@KonunantuLnx:~/tesis/Code/Django/pjWeTwoo$ django-admin.py compilemessages
processing file django.po in /home/alvaro/tesis/Code/Django/pjWeTwoo/locale/es/LC_MESSAGES

Installing Setup tools of Python:

alvaro@KonunantuLnx:~/Desktop$ sudo sh setuptools-0.6c9-py2.5.egg
[sudo] password for alvaro:
Processing setuptools-0.6c9-py2.5.egg
Copying setuptools-0.6c9-py2.5.egg to /usr/lib/python2.5/site-packages
Adding setuptools 0.6c9 to easy-install.pth file
Installing easy_install script to /usr/bin
Installing easy_install-2.5 script to /usr/bin

Installed /usr/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg
Processing dependencies for setuptools==0.6c9
Finished processing dependencies for setuptools==0.6c9

Install Open SSH Server for remote connections

Usefully when I lost connection o mouse pointer doesn’t work in remote connection using VNC Viewer client (on Windows)

alvaro@KonunantuLnx:~$ sudo apt-get install openssh-server
[sudo] password for alvaro:
Reading package lists… Done

For install a Windows client of SSH, I used PuTTY (http://www.openssh.com/windows.html)

The Python Language

I read that Python doesn’t support Enum Types and Switch-Case statements, So, I’ll use for now Lists and if-else’s :P

Django Config mail for send error

http://docs.djangoproject.com/en/dev/topics/email/

http://docs.djangoproject.com/en/dev/howto/error-reporting/

Django programming guide (styles)

http://docs.djangoproject.com/en/dev/internals/contributing/#coding-style

Facebook Feeds templates:

{*actor*} {*invited*} {*target*} {*todiscover*} <a href=”{*linktemplate*}”>{*piename*}</a> {*enddetails*}

{“invited”:”invitó”,”todiscover”:”a descubrir”,
“piename”:”Torta de Relaciones Amorosas”,
“linktemplate”:”http://apps.facebook.com/wetwooapp/?f=template123456789&#8243;,
“enddetails”:”de sus amigos”,
“images”:[{"src":"http://pad.thedigitalmovement.com/_blaise/2007-06-15-dgen-breakfast.jpg", "href":"http://www.facebook.com"}, {"src": "http://pad.thedigitalmovement.com/_blaise/2007-06-13-roger-waters.jpg", "href":"http://www.facebook.com"}]}

using percent symbol in Python

http://www.agapow.net/programming/python/using-percent-in-a-string

FB User plolycy

http://wiki.developers.facebook.com/index.php/Platform_Policy

Config /etc/network/interfaces

auto eth0
iface eth0 inet static
address 192.168.2.3
netmask 255.255.255.0
gateway 192.168.2.1
iface lo inet loopback

Using IPython to test functions of WeTwoo. Importing functions

To use WeTwoo function from python console, you should, inside directory of wetwoo project, run:

This post will show the steps necessary to FINISH my thesis and will help me to reproduce the steps in case that some issue make me have start again. Why English. just for practice :)

  • Install Ubuntu 8.10
  • Configure sound (to work in nice place :P). See my other post related
  • Install my printer driver (see my other post related)
  • Install RapidSVN. RapidSVN is gui client for Subversion. In windows I use TortoiseSVN
  • Add repository to RapidSVN
  • Install PostgerSQL. Synaptic Package Manager should show:

PostgreSQL Installation

    postgresql (version 8.3.5-0ubuntu8.10) will be installed
    postgresql-8.3 (version 8.3.5-0ubuntu8.10) will be installed
    postgresql-client-8.3 (version 8.3.5-0ubuntu8.10) will be installed
    postgresql-client-common (version 90) will be installed
    postgresql-common (version 90) will be installed

After I've installed postgresql, I followed the steps that Dav show in they blog (http://hocuspokus.net/2008/05/13/install-postgresql-on-ubuntu-804/) Install PostgreSQL on Ubuntu 8

Account for postgres that I made is postgres with “mitesis” as password

Install Subversion client to be used in command line
alvaro@KonunantuLnx:~$ sudo apt-get install subversion

Install Django

Read the post to install Django:

http://realm3.com/articles/installing_django_from_source_on_ubuntu_8.10

Django was installed in: /usr/local/lib/django-1.0.2/django/

Install PostgreSQL

Install pyscopq2, Python module for PostgreSql using Synaptic Package Manager

python-egenix-mxdatetime (version 3.1.0-1) will be installed
python-egenix-mxtools (version 3.1.0-1) will be installed
python-psycopg2 (version 2.0.8-0ubuntu1) will be installed

Instal MySQL Server for Mantis.

sudo apt-get install mysql-server

Installation  of Mantis. using Synaptic Package Manager you can install it. Mantis is a :

apache2-mpm-worker will be removed
apache2-mpm-prefork (version 2.2.9-7ubuntu3) will be installed
dbconfig-common (version 1.8.39) will be installed
libapache2-mod-php5 (version 5.2.6-2ubuntu4) will be installed
libdbd-mysql-perl (version 4.007-1build1) will be installed
libdbi-perl (version 1.605-1) will be installed
libnet-daemon-perl (version 0.38-1.1) will be installed
libphp-adodb (version 5.04a-1) will be installed
libphp-phpmailer (version 1.73-6) will be installed
libplrpc-perl (version 0.2017-1.1) will be installed
mantis (version 1.1.2+dfsg-8) will be installed
mysql-client (version 5.0.67-0ubuntu6) will be installed
mysql-client-5.0 (version 5.0.67-0ubuntu6) will be installed
php5 (version 5.2.6-2ubuntu4) will be installed
php5-common (version 5.2.6-2ubuntu4) will be installed
php5-mysql (version 5.2.6-2ubuntu4) will be installed

Install Notes:

libphp-adodb is no longer installed in /usr/share/adodb. New installation path is now /usr/share/php/adodb.

Please update your php.ini file. Maybe you must also change your web-server configuraton.

Message 2:

By default, the mantis package creates an administrator account. The password for this account is ‘root’.

It is highly recommended to change this password immediately after installation is complete.

Forget a mail server, I’ll install:

python-openssl (version 0.7-2) will be installed
python-pam (version 0.4.2-12ubuntu2) will be installed
python-pyopenssl (version 0.7-2) will be installed
python-serial (version 2.3-1) will be installed
python-twisted-bin (version 8.1.0-4) will be installed
python-twisted-core (version 8.1.0-4) will be installed
python-twisted-mail (version 8.1.0-2) will be installed
python-twisted-names (version 8.1.0-1) will be installed
python-zopeinterface (version 3.3.1-7build1) will be installed

I got this wrriting (SMTP) in SPM (Sinaptic Package Manager)

Install Postfix:

alvaro@KonunantuLnx:~$ sudo apt-get install postfix
..other messages in console removed for post..
Postfix is now set up with a default configuration.  If you need to make
changes, edit
/etc/postfix/main.cf (and others) as needed.  To view Postfix configuration
values, see postconf(1).
After modifying main.cf, be sure to run '/etc/init.d/postfix reload'.
Running newaliases

  • Stopping Postfix Mail Transport Agent postfix                         [ OK ]
  • Starting Postfix Mail Transport Agent postfix                         [ OK ]

Processing triggers for libc6 …
ldconfig deferred processing now taking place
alvaro@KonunantuLnx:~$

After Install postfix, I decide work with a external SMTP server because mails sent from my machine were refused in target server, like Gmail.com and Yahoo.es.

The file edited was: config_defaults_inc.php

and the lines:

$g_smtp_host            = ‘mail.aebcagenda.com’;

# These options allow you to use SMTP Authentication when you use a remote
# SMTP host with phpMailer.  If smtp_username is not ” then the username
# and password will be used when logging in to the SMTP server.
$g_smtp_username = ‘mantis+aebcagenda.com’;
$g_smtp_password = ‘************’;

Once configurated SMTP Server, Mantis doesn’t work correctly with mail too, so I modified the file

class.phpmailer.php and I added

define( 'PHPMAILER_PATH', 'libphp-phpmailer' . DIRECTORY_SEPARATOR );

into line 20 and after restart the apache, Mantis was able to send mail to gmail :) without problems.
Note: I found a post in http://www.mantisbt.org/forums/viewtopic.php?f=3&t=3223 regarding to this issue that help me.

Steps with Django.. for final app

alvaro@KonunantuLnx:~/tesis/Code/Django/pjWeTwoo$ python manage.py syncdb
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site

You just installed Django’s auth system, which means you don’t have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (Leave blank to use ‘alvaro’):
E-mail address: alvarobrange@gmail.com
Password:
Password (again):
Superuser created successfully.
Installing index for auth.Permission model
Installing index for auth.Message model
alvaro@KonunantuLnx:~/tesis/Code/Django/pjWeTwoo$

PostgreSQL – Contrib and how to use dblink function

dblink function allow us acess to remote postgresql database. In order to use it, you must:

  • Install PostgreSQL contrib package, which provides several additional features for the PostgreSQL database. contrib often serves as a testbed for

features before they are adopted into PostgreSQL proper.

  • Execute dblink sql in pgadmin. dblink.sql is located in /usr/share/postgresql/8.3/contrib in Ubuntu:

For details see:

dblink

http://www.experts-exchange.com/Databases/PostgreSQL/Q_21902314.html

I tested with the follow code:

CREATE TABLE d_user_temp AS SELECT first_name
FROM dblink('hostaddr=192.168.2.3 dbname=wetwoo user=miuser password=mipassword', 'SELECT first_name FROM wetwoo_person')
AS f(first_name character varying(200))

IPython was installed. Recommended by Django. Details about Ipython http://ipython.scipy.org/moin/

Some django utils commands and paths:

Check: http://docs.djangoproject.com/en/dev/ref/django-admin/

Reset database:

alvaro@KonunantuLnx:~/tesis/Code/Django/pjWeTwoo$ python manage.py reset wetwoo

Show changes carried out to reset without do it.

alvaro@KonunantuLnx:~/tesis/Code/Django/pjWeTwoo$ python manage.py sqlreset wetwoo

To find out your system’s site-packages location, execute the following:
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

Paths
This folder has admin files of Django:
/usr/local/lib/django-1.0.2/django/contrib/admin/templates/admin

Media file of Django

/usr/local/lib/django-1.0.2/django/contrib/admin/media/

Django Evolution

Project Web Site: http://code.google.com/p/django-evolution/

This allow you update your model after initial syncdb. Usage:
Before we start making changes to “models.py“, we need to set up the
project to allow evolutions. To do this, we add “django_evolution“ to the
“settings.INSTALLED_APPS“ and run “./manage.py syncdb“. This sets up
the tables for tracking model changes::

$ ./manage.py syncdb
Creating table django_evolution
Installing baseline version for testproject.blogette
Loading 'initial_data' fixtures...
No fixtures found.

Now we can go into “models.py“ remove the “date_of_birth“ field.
After removing the field, “./manage.py syncdb“ will provide a warning
that changes have been detected::

$ ./manage.py syncdb
Project signature has changed - an evolution is required
Loading 'initial_data' fixtures...
No fixtures found.

Django links for documentation:

Queries: http://docs.djangoproject.com/en/dev/topics/db/queries/#topics-db-queries

Commands: http://docs.djangoproject.com/en/dev/ref/django-admin

Initial data for models: http://docs.djangoproject.com/en/dev/howto/initial-data/#providing-initial-sql-data

Model Meta Options: http://docs.djangoproject.com/en/dev/ref/models/options/#django.db.models.Options.unique_together

Fields: http://docs.djangoproject.com/en/dev/ref/models/fields/

Many to many relationships: http://www.djangoproject.com/documentation/models/many_to_many/

Settings in Django http://docs.djangoproject.com/en/dev/ref/settings/

Django with Apache.

Information: http://docs.djangoproject.com/en/dev/howto/deployment/modpython

In order to work with Apache, we needs install mod-python installed

libapache2-mod-python (version 3.3.1-3) will be installed
libapache2-mod-python-doc (version 3.3.1-3) will be installed

<Location "/mysite/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE pjWeTwoo.settings
PythonOption django.root /mysite
PythonDebug On
PythonPath "['/usr/lib/python2.5/site-packages','/home/alvaro/tesis/Code/Django/','/home/alvaro/tesis/Code/Django/pjWeTwoo'] + sys.path"
</Location>

Django with Apache and Lighttpd for server static files

http://www.inerciasensorial.com.br/2007/06/10/perils-of-software-development/lighttpd-with-apache/

Symbolinc link for admin folder.This allow let the original folder without change and update the django code from SVN without needs for update manually other folder.

alvaro@KonunantuLnx:/var/www$ sudo ln -s /usr/local/lib/django-1.0.2/django/contrib/admin/media media

Apache Config file was added to respository. To do it, I make a symbolic link:

alvaro@KonunantuLnx:/etc/apache2/sites-available$ sudo ln -s /home/alvaro/tesis/Code/Django/pjWeTwoo/Config_files/apache2/default default
alvaro@KonunantuLnx:/etc/apache2$ sudo ln -s /home/alvaro/tesis/Code/Django/pjWeTwoo/Config_files/apache2/httpd.conf httpd.conf
alvaro@KonunantuLnx:/etc/lighttpd$ sudo ln -s /home/alvaro/tesis/Code/Django/pjWeTwoo/Config_files/lighttpd/lighttpd.conf lighttpd.conf

Linux Commands:
  • List directory or files permissions. To change, use chmod or sudo chmod
alvaro@KonunantuLnx:/var/www/media$ ls -l
  • Know the process that are running and owner of it: alvaro@KonunantuLnx:/etc/lighttpd$ ps aux

Other web pages/links

http://www.freesoftwaremagazine.com/articles/users_in_ubuntu?page=0%2C0 show information about user and groups

Download PyFacebook:

alvaro@KonunantuLnx:~/tesis/Code/Django/pjWeTwoo/pyfacebook$ svn checkout http://pyfacebook.googlecode.com/svn/trunk/ pyfacebook-read-only
Install PyFacebook:

alvaro@KonunantuLnx:~/tesis/Code/Django/pjWeTwoo/pyfacebook$ sudo python setup.py install
[sudo] password for alvaro:
running install
running build
running build_py
running install_lib
creating /usr/lib/python2.5/site-packages/facebook
creating /usr/lib/python2.5/site-packages/facebook/djangofb
copying build/lib/facebook/djangofb/context_processors.py -> /usr/lib/python2.5/site-packages/facebook/djangofb
copying build/lib/facebook/djangofb/models.py -> /usr/lib/python2.5/site-packages/facebook/djangofb
copying build/lib/facebook/djangofb/__init__.py -> /usr/lib/python2.5/site-packages/facebook/djangofb
copying build/lib/facebook/wsgi.py -> /usr/lib/python2.5/site-packages/facebook
copying build/lib/facebook/__init__.py -> /usr/lib/python2.5/site-packages/facebook
byte-compiling /usr/lib/python2.5/site-packages/facebook/djangofb/context_processors.py to context_processors.pyc
byte-compiling /usr/lib/python2.5/site-packages/facebook/djangofb/models.py to models.pyc
byte-compiling /usr/lib/python2.5/site-packages/facebook/djangofb/__init__.py to __init__.pyc
byte-compiling /usr/lib/python2.5/site-packages/facebook/wsgi.py to wsgi.pyc
byte-compiling /usr/lib/python2.5/site-packages/facebook/__init__.py to __init__.pyc
running install_egg_info
Writing /usr/lib/python2.5/site-packages/pyfacebook-0.1.egg-info

For get example  for Django and Facebook, I followed the post of SHABDA which help me a lot :)

Change name to folder:

alvaro@KonunantuLnx:/var/www/media/img$ sudo rename -f pwd heart.jpg
Bareword “pwd” not allowed while “strict subs” in use at (eval 1) line 1.
alvaro@KonunantuLnx:/var/www/media/img$ sudo mv pwd heart.jpg

Install NumPy (performing a search into Synaptic Package Manger)

libblas3gf (version 1.2-1.6) will be installed
libgfortran3 (version 4.3.2-1ubuntu12) will be installed
liblapack3gf (version 3.1.1-0.4ubuntu1) will be installed
python-dbg (version 2.5.2-1ubuntu1) will be installed
python-numpy (version 1:1.1.1-1) will be installed
python-numpy-dbg (version 1:1.1.1-1) will be installed
python-numpy-doc (version 1:1.1.1-1) will be installed
python2.5-dbg (version 2.5.2-11.1ubuntu1) will be installed

Install matplotlib (Synaptic Package Manager)

dvipdfmx (version 1:20071115-1) will be installed
dvipng (version 1.11-1) will be installed
latex-beamer (version 3.07-1ubuntu1) will be installed
latex-xcolor (version 2.11-1) will be installed
libt1-5 (version 5.1.2-2) will be installed
lmodern (version 1.010x-5) will be installed
pgf (version 2.00-1) will be installed
prosper (version 1.00.4+cvs.2007.05.01-3) will be installed
python-dateutil (version 1.4-1ubuntu2) will be installed
python-excelerator (version 0.6.3a-3) will be installed
python-matplotlib (version 0.98.3-4ubuntu1) will be installed
python-matplotlib-data (version 0.98.3-4ubuntu1) will be installed
python-pyparsing (version 1.5.0-1) will be installed
python-tz (version 2008b-3ubuntu1) will be installed
tetex-bin (version 2007.dfsg.1-2) will be installed
tex-common (version 1.11) will be installed
texlive (version 2007.dfsg.1-2) will be installed
texlive-base (version 2007.dfsg.1-2) will be installed
texlive-base-bin (version 2007.dfsg.2-3ubuntu1) will be installed
texlive-base-bin-doc (version 2007.dfsg.2-3ubuntu1) will be installed
texlive-common (version 2007.dfsg.1-2) will be installed
texlive-doc-base (version 2007.dfsg.1-1) will be installed
texlive-fonts-recommended (version 2007.dfsg.1-2) will be installed
texlive-fonts-recommended-doc (version 2007.dfsg.1-2) will be installed
texlive-generic-recommended (version 2007.dfsg.1-2) will be installed
texlive-latex-base (version 2007.dfsg.1-2) will be installed
texlive-latex-base-doc (version 2007.dfsg.1-2) will be installed
texlive-latex-recommended (version 2007.dfsg.1-2) will be installed
texlive-latex-recommended-doc (version 2007.dfsg.1-2) will be installed
texlive-pstricks (version 2007.dfsg.2-1ubuntu1) will be installed
texlive-pstricks-doc (version 2007.dfsg.2-1ubuntu1) will be installed
tipa (version 2:1.3-12) will be installed

Testing charts/graphs with matplotlib

I followed the post of Christiano Anderson about Django and MatPlotLib and I got some issue, but I fix. Here show how:

Error message in web page:
Failed to create /var/www/media/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data
Solution:
Then, I added this lines:
def chart(request):
import os
import dbus
os.environ['HOME'] = ‘/var/www/media’

Linl to ussful standart about files:

http://www.ietf.org/rfc/rfc2183.txt

Aptana Installation on Ubuntu 8.10

I followed instruction that  Andrew Bleakley states on his blog

Django Internationalization

This coomands help to translate and compille the language files:

alvaro@KonunantuLnx:~/tesis/Code/Django/pjWeTwoo$ django-admin.py makemessages -l es
processing language es
alvaro@KonunantuLnx:~/tesis/Code/Django/pjWeTwoo$ django-admin.py compilemessages
processing file django.po in /home/alvaro/tesis/Code/Django/pjWeTwoo/locale/es/LC_MESSAGES

Installing Setup tools of Python:

alvaro@KonunantuLnx:~/Desktop$ sudo sh setuptools-0.6c9-py2.5.egg
[sudo] password for alvaro:
Processing setuptools-0.6c9-py2.5.egg
Copying setuptools-0.6c9-py2.5.egg to /usr/lib/python2.5/site-packages
Adding setuptools 0.6c9 to easy-install.pth file
Installing easy_install script to /usr/bin
Installing easy_install-2.5 script to /usr/bin

Installed /usr/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg
Processing dependencies for setuptools==0.6c9
Finished processing dependencies for setuptools==0.6c9

Install Open SSH Server for remote connections

Usefully when I lost connection o mouse pointer doesn’t work in remote connection using VNC Viewer client (on Windows)

alvaro@KonunantuLnx:~$ sudo apt-get install openssh-server
[sudo] password for alvaro:
Reading package lists… Done

For install a Windows client of SSH, I used PuTTY (http://www.openssh.com/windows.html)

The Python Language

I read that Python doesn’t support Enum Types and Switch-Case statements, So, I’ll use for now Lists and if-else’s :P

Django Config mail for send error

http://docs.djangoproject.com/en/dev/topics/email/

http://docs.djangoproject.com/en/dev/howto/error-reporting/

Django programming guide (styles)

http://docs.djangoproject.com/en/dev/internals/contributing/#coding-style

Facebook Feeds templates:

{*actor*} {*invited*} {*target*} {*todiscover*} <a href=”{*linktemplate*}”>{*piename*}</a> {*enddetails*}

{“invited”:”invitó”,”todiscover”:”a descubrir”,
“piename”:”Torta de Relaciones Amorosas”,
“linktemplate”:”http://apps.facebook.com/wetwooapp/?f=template123456789&#8243;,
“enddetails”:”de sus amigos”,
“images”:[{"src":"http://pad.thedigitalmovement.com/_blaise/2007-06-15-dgen-breakfast.jpg", "href":"http://www.facebook.com"}, {"src": "http://pad.thedigitalmovement.com/_blaise/2007-06-13-roger-waters.jpg", "href":"http://www.facebook.com"}]}

using percent symbol in Python

http://www.agapow.net/programming/python/using-percent-in-a-string

FB User plolycy

http://wiki.developers.facebook.com/index.php/Platform_Policy

Config /etc/network/interfaces

auto eth0
iface eth0 inet static
address 192.168.2.3
netmask 255.255.255.0
gateway 192.168.2.1
iface lo inet loopback

Using IPython to test functions of WeTwoo. Importing functions

To use WeTwoo function from python console, you should, inside directory of wetwoo project, run:

python manage.py shell

In [1]: import wetwoo.helper
In [2]: wetwoo.helper.calculateFriendsInCommon(…)

Install NetworkX

libsuitesparse-3.1.0 (version 3.1.0-3) will be installed
libyaml-0-1 (version 0.1.1-1) will be installed
python-networkx (version 0.36-2) will be installed
python-pygraphviz (version 0.36-1) will be installed
python-scipy (version 0.6.0-11) will be installed
python-yaml (version 3.05-2) will be installed


Follow

Get every new post delivered to your Inbox.

Join 228 other followers