레이블이 python인 게시물을 표시합니다. 모든 게시물 표시
레이블이 python인 게시물을 표시합니다. 모든 게시물 표시

2013년 8월 16일 금요일

centos 5.9 python 2.7 python-ldap 설치

yum installl openldap24-libs.i386
yum installl openldap24-libs.x86_64
yum installl openldap24-libs-devel.i386
yum installl openldap24-libs-devel.x86_64

python-ldap-2.4.13.tar.gz download

tar -xvzf python-ldap-2.4.13.tar.gz

cd python-ldap-2.4.13
emacs setup.cfg

lib 에 /usr/lib64/openldap24 ,/usr/lib/openldap24 추가
include 에 /usr/include/openldap24 추가

python setup.py install




2013년 8월 14일 수요일

mac ldap lib 설치

http://projects.skurfer.com/posts/2011/python_ldap_lion/

rb 파일만 넣고
brew install하면 끝남.

그후에 python-ldap 하면 됨.

python ldap 2.3.13

https://pypi.python.org/pypi/python-ldap/2.3.13


centos 6
yum install openldap24-libs-devel.x86_64

2013년 8월 13일 화요일

python mysql connector 설치 및 SQLAachemy 연동

You can use the MySQL Connector/Python
Installation via PyPip
pip install mysql-connector-python
Further information can be found on the MySQL Connector/Python 1.0.5 beta announcement blog.
On Launchpad there's a good example of how to add-, edit- or remove data with the library.



MySQL-Connector Notes

Support for the MySQL database via the MySQL Connector/Python adapter.
MySQL Connector/Python is available at:

Connecting

Connect string format:
mysql+mysqlconnector://<user>:<password>@<host>[:<port>]/<dbname>

http://docs.sqlalchemy.org/en/rel_0_7/dialects/mysql.html#id5

2013년 7월 25일 목요일

python profiler

http://stackoverflow.com/questions/110259/which-python-memory-profiler-is-recommended

2013년 7월 16일 화요일

emacs + python에서 auto indent

(add-hook 'python-mode-hook '(lambda () (define-key python-mode-map "\C-m" 'newline-and-indent)))

emacs python할때 현재 폴더에 있는 모듈을 불러오지 못할때.

http://stackoverflow.com/questions/2658475/python-mode-import-problem

.emace.d/init.el에

(defun python-reinstate-current-directory ()
  "When running Python, add the current directory ('') to the head of sys.path.
For reasons unexplained, run-python passes arguments to the
interpreter that explicitly remove '' from sys.path. This means
that, for example, using `python-send-buffer' in a buffer
visiting a module's code will fail to find other modules in the
same directory.

Adding this function to `inferior-python-mode-hook' reinstates
the current directory in Python's search path."
  (python-send-string "sys.path[0:0] = ['']"))

(add-hook 'inferior-python-mode-hook 'python-reinstate-current-directory)

위와 같이 추가

2012년 7월 17일 화요일

python + unbutu notification

http://developer.ubuntu.com/resources/technologies/notification/2/#icon-summary-body-python


#!/usr/bin/python
################################################################################
##3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
##      10        20        30        40        50        60        70        80
##
## Info:
##    Example of how to use libnotify correctly and at the same time comply to
##    the new jaunty notification spec (read: visual guidelines)
##
## Run:
##    chmod +x icon-summary-body.py
##    ./icon-summary-body.py
##
## Copyright 2009 Canonical Ltd.
##
## Author:
##    Mirco "MacSlow" Mueller <mirco.mueller@canonical.com>
##
## This program is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License version 3, as published
## by the Free Software Foundation.
##
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranties of
## MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
## PURPOSE.  See the GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License along
## with this program.  If not, see <http://www.gnu.org/licenses/>.
##
################################################################################
import sys
import pynotify
# even in Python this is globally nasty <img src="http://developer.ubuntu.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley"> , do something nicer in your own code
capabilities = {'actions':             False,
        'body':                False,
        'body-hyperlinks':     False,
        'body-images':         False,
        'body-markup':         False,
        'icon-multi':          False,
        'icon-static':         False,
        'sound':               False,
        'image/svg+xml':       False,
        'private-synchronous': False,
        'append':              False,
        'private-icon-only':   False}
def initCaps ():
    caps = pynotify.get_server_caps ()
    if caps is None:
            print "Failed to receive server caps."
        sys.exit (1)
    for cap in caps:
        capabilities[cap] = True
def printCaps ():
    info = pynotify.get_server_info ()
    print "Name:          " + info["name"]
    print "Vendor:        " + info["vendor"]
    print "Version:       " + info["version"]
    print "Spec. Version: " + info["spec-version"]
    caps = pynotify.get_server_caps ()
    if caps is None:
            print "Failed to receive server caps."
        sys.exit (1)
    print "Supported capabilities/hints:"
    if capabilities['actions']:
        print "\tactions"
    if capabilities['body']:
        print "\tbody"
    if capabilities['body-hyperlinks']:
        print "\tbody-hyperlinks"
    if capabilities['body-images']:
        print "\tbody-images"
    if capabilities['body-markup']:
        print "\tbody-markup"
    if capabilities['icon-multi']:
        print "\ticon-multi"
    if capabilities['icon-static']:
        print "\ticon-static"
    if capabilities['sound']:
        print "\tsound"
    if capabilities['image/svg+xml']:
        print "\timage/svg+xml"
    if capabilities['private-synchronous']:
        print "\tprivate-synchronous"
    if capabilities['append']:
        print "\tappend"
    if capabilities['private-icon-only']:
        print "\tprivate-icon-only"
    print "Notes:"
    if info["name"] == "notify-osd":
        print "\tx- and y-coordinates hints are ignored"
        print "\texpire-timeout is ignored"
        print "\tbody-markup is accepted but filtered"
    else:
        print "\tnone"
if __name__ == '__main__':
    if not pynotify.init ("icon-summary-body"):
        sys.exit (1)
    # call this so we can savely use capabilities dictionary later
    initCaps ()
    # show what's supported
    printCaps ()
    # try the icon-summary-body case
    n = pynotify.Notification ("Cole Raby",
                   "Hey pal, what's up with the party "
                   "next weekend? Will you join me "
                   "and Anna?",
                   "notification-message-im")
    n.show ()