web.py nginx-egaz erabiltzeko fastcgi moduen spawn-fcgi-gaz debian gnu/linux-en

Instalaziñue: su aptitude install nginx-full spawn-fcgi python-pip pip install web.py exit Proiektuentzako karpeta bat sortu, adibidez: mkdir /home/projects/zpy mkdir /home/projects/zpy/private mkdir /home/projects/zpy/public mkdir /home/projects/zpy/public/static touch /home/projects/zpy/private/zpy.py Haulako estrukturie okingo lekidau: . ├── private │   └── zpy.py └── public └── static Oin python-en script-e fcgi moduen erabiltzeko: nano /home/projects/zpy/zpy.py #!/usr/bin/env python # -*- coding: utf-8 -*- […]

php array multi-dimensional bat python dict bihurtu

Ba hamen gabilz barriro python-egaz pellikan, oingutan php-tik curl bidez botaku array multi-dimensional bat post edo get bidez eta python-egaz hartun. Okin biharrekuek: python, web zerbitzaridxe php-gaz eta cgi-gaz Paketiek instala: su aptitude install python-pip php5-curl pip install querystring-parser exit curl.class.php artxibue: <?php class curl { public static function getURL($url, $params = array(), $type = […]

debian / python: sqlalchemy -gaz oracle -ra konekta

Paketiek instala: su aptitude install python-sqlalchemy alien libaio1 exit Jakitzeko ze bertsiño dakun python-ena: python -V erantzune: Python 2.7.2+ Jakitzeko oracle-n bertsiñue: select * from product_component_version; erantzune: NLSRTL                                  11.2.0.2.0 Production Oracle Database 11g Enterprise Edition  11.2.0.2.0 64bit Production PL/SQL                                  11.2.0.2.0 Production TNS for 64-bit Windows:                 11.2.0.2.0 Production Nire kasuen: python 2.7 eta oracle 11.2 Orduen […]

python: gaurko erabiltzaile batzun tweet-ek wordpress-en publike

Hamen azken fiñien script-e akabata #!/usr/bin/env python # -*- coding: utf-8 -*- import sys import urllib import datetime as date import time import simplejson as json import re import MySQLdb def getTweets(id):     now = date.datetime.now().strftime(“%Y-%m-%d”)     url = “http://search.twitter.com/search.json?q=+from%3A”+u+”+since%3A”+now     json_text = urllib.urlopen(url).read()     json_obj = json.loads(json_text)     tweets = []     for result […]

python: adierazpen erregularrakaz (regex) link-ek html-ra bihurtu

baguez kallue hartzien python-eri, oingutan texto batetik link-ek html-ra pasa’kuz #!/usr/bin/env python # -*- coding: utf-8 -*- import re text = “http://aaaaa       https://bbbbb ftp://ccccc\n http://dddddddd” m = re.sub(r'(?i)(^|\s+|\A)(http|https|ftp)(\://\S+)(\s+|\Z|$)’, ‘\\1<a href=\”\\1\\2\” onclick=\”window.open(this.href); return false;\”>\\2\\3</a>\\4’, text) print m Erantzune:   <a href=”http://aaaaa” onclick=”window.open(this.href); return false;”>       <a href=”https://bbbbb” onclick=”window.open(this.href); return false;”> <a href=”ftp://ccccc” onclick=”window.open(this.href); return false;”>  <a href=”http://dddddddd” […]

python: web2py apache-gaz imiñi martxan debian gnu/linux-en mod-wsgi bidez

web2py python-en framework bat da web aplikaziñuek python-egaz eitzeko, instalateko hau script-e prepara dot, kanbije usuaidxue, grupue eta proiektuen karpetie zeuon gustora: 1go gauzie root moduen konekta eta script-e sortu: su nano web2py_install.sh #!/bin/bash user=’zital’ group=$user project_path=’/home/projects’ current_path=`echo $PWD` me=`whoami` if [ “$me” == “root” ] then aptitude -y install libapache2-mod-wsgi unzip wget cd ${project_path} […]

python: tweet-eri tag bidezko iragazki bet pasa

Bueno ariñauko post-an ikusi’du zelan hartun python-egaz gaurko eguneko tweet-ek, bueno ba oingutan horreri tweeteri tag bidezko iragazki bet eingo’tzagu gai batzuri buruzko tweet-ek interesa doskuzelako eta ez edozein: #!/usr/bin/python2.6 # -*- coding: utf-8 -*- import urllib import datetime as date import time import simplejson as json import re users = [‘ZiTAL’, ‘g0re_k’] tags = […]

python: gaurko tweet-ak hartzeko script-a

Neure lehenengo python script-e: Zelan hartun gaurko eguneko tweet-ak Biher dana instala eta script-e edite: su aptitude install python2.6 python-simplejson exit nano ztwitter.py #!/usr/bin/python2.6 # -*- coding: utf-8 -*- import urllib import datetime as date import time import simplejson as json users = [‘ZiTAL’, ‘g0re_k’] now = date.datetime.now() now = now.strftime(“%Y-%m-%d”) for u in users: […]

python: AttributeError: ‘module’ object has no attribute ‘X’

Python-egaz imintzen naien bakotzien beti dakot problemaren bat. Gaurkuen python-en twitter-eko moduluegaz. su aptitude install python-twitter exit Bueno eta ez dast okurridu beste izenik script-entzako twitter.py baño haunegaz edukidxegaz: #!/usr/bin/python2.6 # -*- coding: utf-8 -*- import twitter api = twitter.Api() Ejekuteteko baimenak emon eta martxan imiñi: chmod +x twitter.py ./twitter.py Errorie: AttributeError: ‘module’ object has […]