Tuesday, 2 April 2013

Use of eval in python

The eval function lets a python program run python code within itself.
eval example (interactive shell):
>>> x = 1
>>> eval('x + 1')
2
>>> eval('x')
1
 
eval() interprets a string as code. The reason why so many people have warned you about using this is because a user can use this as an option to run code on the computer. If you have eval(input())and os imported, a person could type into input() os.system('rm -R *') which would delete all your files in your home directory. (Assuming you have a unix system). Using eval() is a security hole. If you need to convert strings to other formats, try to use things that do that, like int(). 

Thursday, 28 February 2013

Have You tried this?

This will work in linux terminal.Try this it's too funny.

1. Open terminal
2. Type apt-get moo
3. Press Enter.
3. and you will get the Moo!

I had not put a screen shot here. just try it!


Wednesday, 23 January 2013

Install SVN(subversion) in ubuntu 12.04

This blog post will cover how to install SVN (subversion) in ubuntu 12.04
Open terminal and run below commands. it will install SVN(subversion).


sudo apt-get install subversion

now you need to run the basic SVN command to get the branch, push and pull the branch from the assembla

Saturday, 12 January 2013

Create Desktop Launcher to start OpenERP server

Many end user don't know how to start OpenERP server from the terminal. Desktop launcher is the best way to start the OpenERP server for the non technical end user. Start up service is another way to start the OpenERP server automatically.
for that you need to install gnome panel. Install gnome-panel by running below command in ubuntu terminaAl.
sudo apt-get install gnome-panel  

Make a bash script which will run the OpenERP server. To make bash script create new file and write script as below.

#!/bin/bashcd <<path to openerp server>>#e.g. /home/mypc/openerp/server/python openerp-server --addons ../addons/,../openerp-web/addons/
and save it with .sh extension e.g server_start.sh 

now again write this in terminal 


gnome-desktop-item-edit --create-new ~/Desktop
 it will open a window as 

Add Launcher name as you wish. in the command give the path of the bash file(make sure the file is executable). and click ok. it will create a icon on the desktop.

Monday, 31 December 2012

Install required python packages for OpenERP v 7.0

To install OpenERP v7 on linux machine you required various python library. Run below command, it includes all python libraries in only one line.
sudo apt-get install python-dateutil python-docutils python-feedparser python-gdata python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid python-psycopg2 python-psutil python-pybabel python-pychart python-pydot python-pyparsing python-reportlab python-simplejson python-tz python-unittest2 python-vatnumber python-vobject python-webdav python-werkzeug python-xlwt python-yaml python-zsi python-psutil

Friday, 28 December 2012

Python script to backup all database

list all the database from the  postgresql server, 
run the query in postgresql 

psql SELECT datname FROM pg_database;

it will list all the database from the postgres server. copy and paste it in one text file. and run the script.

import os

lines = [line.strip() for line in open('<<path to file>>')]
for i in lines:
    print os.system("pg_dump %s >
<<path to file>>%s.out" % (i,i))

it will dump all the database in particulate folder

Tuesday, 6 November 2012

List Used Port in Ubantu

netstat is the command which prints network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
change the user as root using
sudo -i
netstat -tulpn
 

it will list all the local address on the local system used by the program.