AndresVargas
Hi!, my nickName is zodman, im a Computer science Engineering.
love the FLOSS and FreeSoftware. Python ninja and php coder.
On left my love Aisha and me.
Interest links
seen more
meteorasite
Claro que puedes usar meteora con django:
demo:
http://djangometeora.vampirito.com.mx
En espera de mas ..
http://github.com/zodman/djangometeora
http://github.com/zodman/meteorasite
ar.pycon.org
Conferencia de python en argentina
Aunque ARG esta muy lejos me gusto que exista este evento en area latinoamericana.
Por supuesto mandare paper y pedire permiso en la oficina para asistir!!
Fechas:
Propuesta de Charlas: Hasta el de 29 de Junio de 2009 (inclusive)
Conferencia: Viernes 4 y Sábado 5 de Septiembre de 2009
python en una sola linea
http://blog.sigfpe.com/2008/09/on-writing-python-one-liners.html aaaaah que bonito!!!!!!
easygui a module for make easy dialogs with Tk
Reading the bucio blog at planetalinux talking about zenity that remember me the easygui module what think can be solve the same problems of zenity (or not alls ) without the gnome(gtk) deps.
python -m easygui
So with it you can make a small dirty tk gui's:
python -c "import easygui; easygui.boolbox('Are ok')"
python -c "import easygui; print easygui.ccbox('zodman continue')"
for Foresight users its packaged on fl:2-devel
sudo conary update easygui=@fl:2-devel
vim python support on foresight
im update few days ago the vim.. on fl:2-devel someone add the params for get the python support im only bake the changes but now i have vim with python powers....
This because the vim version on conary repo not have support of it. So the rpathians what use ? emacs ? argh!!! ( i dont like)
this make the onmicomplete awesome. and with vim-addons( zodyrepo.rpath.org@rpl:devel ) can be a replace of any IDE.
Some python code what i learned today [Iterator]:
In [1]: a = ["a","b","c"] In [2]: b = iter(a) In [3]: b.next() Out[3]: 'a' In [4]: b.next() Out[4]: 'b' In [5]: b.next() Out[5]: 'c' In [6]: b.next() --------------------------------------------------------------------------- StopIteration Traceback (most recent call last) /home/zodman/<ipython console> in <module>() StopIteration:
Im love python because sometimes not need explains for understand what doing ...
imageshack.us client with python powers
Im searching about the a cli what can i upload images to imageshack.us and not found on google....
So i write my own client.
#!/usr/bin/env python import urllib2 from poster.encode import multipart_encode from poster.streaminghttp import register_openers API_URL = 'http://www.imageshack.us/index.php' def yesno(x): if x: return 'yes' else: return 'no' def upload_file(filename, optsize=None, user_cookie=None, remove_bar=True, tags=None, public=True, ): register_openers() data = {'fileupload' :open(filename), 'xml':yesno(True) } datagen, headers = multipart_encode(data) # Some optional parameters if optsize: data['optsize'] = optsize if user_cookie: data['cookie'] = user_cookie if tags: data['tags'] = tags req = urllib2.Request(API_URL, datagen,headers) u = urllib2.urlopen(req) return u.read() if __name__ == "__main__": import sys print upload_file(sys.argv[1])
the result here:

This small app. needs module poster what make the encode multipart life easy. (on foresight its on fl:2-devel xD )
Yeah it need more hack .. hackimages github repo
Update a app with conary-lib
Yeah im add a method for a simple: conary update app<=repo@tag:label>
Reading the documentation and seen some code im understand some things....
- For conary update a package ( called installing a package) need to create a Job
- With this job its a empty for begining. You must attach some task like (Update)
- If job created the update must Apply for install it.
- for update a package needs be a ChangeSpec Format:
(troveName, (oldVersionSpec, oldFlavor), (newVersionSpec, newFlavor) - conary.conary.ConaryClient its the base of conary Structure on Conary API.
From command line:
[zodman@cosmogirl conary-lib]$ conary q iftop iftop was not found [zodman@cosmogirl conary-lib]$ sudo python conarypk.py Update Success of iftop=/zodyrepo.rpath.org@rpl:devel/0.17-3-1 [zodman@cosmogirl conary-lib]$ conary q iftop --labels iftop=zodyrepo.rpath.org@rpl:devel/0.17-3-1
the new method:
def update(self, name, installLabel= None): cli = self.cli #get a trove troves = self.request_query(name, installLabel) for trove in troves: trovespec = self.trove_to_spec( trove ) try: # create a Job job = cli.newUpdateJob() # Add Update task to Job cli.prepareUpdateJob(job, cmdline.parseChangeList(trovespec)) # Apply the Job cli.applyUpdateJob(job) # im rulz return "Update Success of %s" % trovespec except NoNewTrovesError: return "no new Troves Found by %s " % trovespec def trove_to_spec(self, trove ): return cmdline.toTroveSpec( trove[0], str(trove[1]), None)
Using conary-lib:
conary = ConaryPk() print conary.update("iftop","zodyrepo.rpath.org@rpl:devel")
conarylib using the conary public api
Doing the hacking of packagekit im reading the code from conaryBackend.py conaryFilter.py Cache.py
Im very lost following the code so im decide make more modular can i posible to do.
BTW im not found some code example or blogpost about how to use the conary public api. Im have to read the code from /usr/bin/conary file. And get some details of conary api.
Only the little help of mkj. I can do a equal of "conary q" and "conary rq"
So im decide to make a small module for basic task ( what can Improvement the packagekit) of conary api. Commands line equal with use the cli conary.
So get check the code:
http://github.com/zodman/conary-lib/
pyExcelerator making xls files with python
This week ended. Im use this lib its called funny pyExcelerator ( remember me terminator movie).
Its a python module for make files compatibles with MS excel Office.
Im try it and can open files with Office 2007, Mac Office and Openoffice. This solve my problems with endusers what a need a reports in excel.
here a example:
from pyExcelerator import * w = Workbook() ws = w.add_sheet('Hey, Dude') ws.write(0, 0, 1) ws.write(1, 0, 1.23) ws.write(2, 0, 12345678) ws.write(3, 0, 123456.78) ws.write(0, 1, -1) ws.write(1, 1, -1.23) ws.write(2, 1, -12345678) ws.write(3, 1, -123456.78) ws.write(0, 2, -17867868678687.0) ws.write(1, 2, -1.23e-5) ws.write(2, 2, -12345678.90780980) ws.write(3, 2, -123456.78) w.save('numbers.xls')
the better of that module its not have deps. so not need a openoffice core/lib for used it.
$ yolk -S name=pyExcelerator -M pyExcelerator
author: Roman V. Kiseliov
author_email: roman@kiseliov.ru
download_url: http://www.sourceforge.net/projects/pyexcelerator
platform: Platform-independent
version: 0.6.0a
Fabric a pythonic tool for deployment
Today im found a list of python-es this very Usefull tool for admin system.
Fabric its a tool for execute commands on remote servers. With it you can automate updates/softwares and others stuff. very Usefull.
example:
set( project = 'awesome-app', fab_hosts = ['n1.cluster.com', 'n2.cluster.com'], ) def deploy(): "Build the project and deploy it to a specified environment." local('mvn package') put('target/$(project).war', '$(project).war') put('install-script.sh', 'install-script.sh') sudo('install-script.sh')
django-meteora
Im working for a 1.5 month on a project on Cancun Quintana Roo.
This projects its make a POS ( point of Sale) for cocobongo the system its on web with backend intereface.
Well im use meteora for ajaxian actions. Meteora its a javascript widgets of mootools. the main developer is Jose Carlos Nieto
With can do a lot of things:
* Autocomplete
* Bubble
* Calendar
* Carousel
* Datagrid
* Dialog
* Editor
* Filebrowser
* Form Control
* Menu
* Notebook
* Picbox
* Popup
* Searchlist
* Selection
* Spinbutton
* Tablesort
* Toolbox
* Treeview
The main developer of meteora, its a php ninja coder so, exist some php-libs for meteora. Im do my project using meteora and make my own meteora lib ( with help of Ivan Zenteno on python.
Its a simple lib for call HttResponse and get some jsonrpc
For now only works on views.
why foresight use python 2.4 ?
Foresight linux use a python 2.4 and all software of python its limited by this.
The answer its here:
http://wiki.rpath.com/wiki/rPath_Linux:rPath_Linux_2#Python_Version
On resume: we limited the of rpath linux stability ( what i think its very well ). But this touch to popular software.
Like gimp 2.6 needs python 2.5 christine needed, another cups solution needs update python well ... only have wait for solve the issue update to python 2.6 (FL-1452) on roadmap to foresight 2.5
im working to the release of foresight 2.5 KenVandine gime the responsability of PackageKit :S
clases para empaquetar software en foresight
¿Quieres aprender a empaquetar software para conary ( osea para Foresight linux)?
El equipo de foresight tiene previsto iniciar una serie de sesiones en IRC que trataran sobre los fundamentos del empaquetamiento Conary.
Vamos a comenzar por lo básico, que abarca sólo la creación de paquetes locales.
Lo siguente será ligeramente más avanzada, y abarcará la creación de su propio proyecto en rBuilder.
Habrá información antes de la clase, para que instales foresight linux y nosotros asumiremos los asistentes se están ejecutando Linux, ya sea Foresight nativa o en una máquina virtual.
El formato será bastante informal
Se iniciará con la creación de un paquete en un editor basado en web que todo el mundo pueda seguir enconjuto. A continuación, se pasara a la creación de paquetes desde cero y teniendo en mentores disponibles para guiar a los nuevos empaquetadores.
Todo el mundo es bienvenido a asistir
Hemos reunido una encuesta, para ayudar a evaluar el interés y la programación. Por favor, rellene este, y déjenos saber si usted ya está familiarizado con Conary y dispuesto a ser mentor.
http://spreadsheets.google.com/viewform?key=pdqA4NNK_btA4OKGyhXvAeQ
Very very usefull django tips
http://ericholscher.com/blog/2008/oct/5/django-tips/
OMG i love that tips.
My Favorite Relatives Import
Django with twitter status
Im add a simple tag on django with my twitter last status. It's cached because twitter haves problems with alots of request...... so here the code
Create a templatetags on your model/ dir
# filename twitter.py from django.template import Library import urllib import simplejson register = Library() @register.simple_tag def twitter_status( username ): url = "http://twitter.com/statuses/user_timeline/%s.json?count=1" % username file = urllib.urlopen(url) json_responce = file.read() twit = simplejson.loads(json_responce) return "%s" % twit[0]["text"]
Add it to my index.html page on templates
{%load cache %} {% cache 18000 twitter %} {% load twitter %} <div class="twitter"> <img src="/static/images/twitter.gif"> @zodman: {% twitter_status "zodman" %} </div> {% endcache %}
Yeap my firts time of used cache on templates. That is very similar of the code of my friend blacknash, he Implement it on blog of h1pp1e
Droopy and Woof
WOOF, WOOF!!! Its not a DOG!!!! Woff is a very usefull python script for share files over the network. You give your IP:port and the file download automatically.
$ woof yucatux_fmat3.png Now serving on http://192.168.254.4:8080/ 192.168.254.4 - - [28/Aug/2008 13:33:23] "GET /yucatux_fmat3.png HTTP/1.1" 200 -
This support filedirs, you can share a dir, and woof make a tarball of it. My favorite python scripts
Droopy isnot a cartoon dog. Its a python script with you can upload file over network. (viceverse of woof)
$ droopy -m "Hellowwwwwwww" -p yucatux_fmat3.png HTTP server running... Check it out at http://localhost:8000 localhost.localdomain - - [28/Aug/2008 13:15:10] "GET / HTTP/1.1" 200 - localhost.localdomain - - [28/Aug/2008 13:15:10] "GET /yucatux_fmat3.png HTTP/1.1" 200 - localhost.localdomain - - [28/Aug/2008 13:15:22] "POST / HTTP/1.1" - - localhost.localdomain - - [28/Aug/2008 13:15:22] *Received: coas.bmp*
The users visit your http://yourIP:8000 and can getyou a file, this is very usefull where you talking with someone on MSN'protocol and send files are very SLOW! open your firewall pass the link and upload the file.
For install on foresight:
conary update {woof,droopy}=zodyrepo.rpath.org@rpl:devel
Pownce and django
UFF this changes its very very hard .......learning by myself how the django signals works an how change adding some stuff....
The idea from integrate pownce and django comes from, i dontlike twitter, and pownce give some stuff can i contrib to others users.
Well i hard to explain my code but this is...
First i create a model what populate from pownce, add a signal on post_save with that signal save a content type what is show, some like timeline of models .... with the pub_date with it i can show on the index of
from django.db import models from django.contrib import databrowse from zodyblog.tumble.models import Item from django.db.models import signals from django.contrib.contenttypes.models import ContentType import django.dispatch class PownceNote(models.Model): pownce_id = models.PositiveIntegerField() body = models.TextField() permalink = models.URLField() date= models.DateTimeField() def get_type(self): pownce_type="Message" if self.powncelink_set.all().count() > 0: pownce_type= "Link" if self.pownceevent_set.all().count() > 0: pownce_type="Event" if self.powncefile_set.all().count() > 0: pownce_type= "File" return pownce_type def __unicode__(self): return "[%s] %s" %(self.get_type(),self.body) class PownceLink(models.Model): url = models.URLField() pownce_note = models.ForeignKey(PownceNote,unique=True) def __unicode__(self): return self.url class PownceFile(models.Model): name = models.CharField(max_length=200) type = models.CharField(max_length=100) pownce_note = models.ForeignKey(PownceNote,unique=True) def __unicode__(self): return self.name class PownceEvent(models.Model): name = models.CharField(max_length=200) ical = models.URLField() location = models.CharField(max_length=200) date = models.DateTimeField() pownce_note = models.ForeignKey(PownceNote,unique=True) def __unicode__(self): return self.name def create_item(sender,instance, **kwargs): ctype = ContentType.objects.get_for_model(instance) if ctype.name == "entrada": pub_date = instance.fecha else: pub_date = instance.date if "created" in kwargs: if kwargs["created"]: si,created = Item.objects.get_or_create(content_type=ctype, object_id=instance.id, pub_date=pub_date) else: si = Item.objects.get(content_type=ctype,object_id=instance.pk) si.pub_date=pub_date si.save() signals.post_save.connect(create_item, sender=PownceNote)
Create a client for download my pownce notelist and updates, thats a simple script with urllib for get content and populate to model
import logging as log log.basicConfig(level=log.DEBUG) import urllib import simplejson import datetime import sys mypath="/home/zodman/lab/dev/zodyblog/" sys.path.append(mypath) from django.core.management import setup_environ from django.utils.dateformat import DateFormat import settings setup_environ(settings) from zodyblog.zodynetwork.models import PownceLink, PownceNote, PownceEvent, PownceFile def link( entry, note ): link = PownceLink(url=entry["link"]["url"]) link.pownce_note = note link.save() def event( entry, note ): event = PownceEvent( name=entry["event"]["name"], ical=entry["event"]["ical"], location=entry["event"]["location"], date=entry["event"]["date"], pownce_note= note ) event.save() def file( entry, note ): file = PownceFile(name=entry["file"]["name"],type=entry["file"]["content_type"],pownce_note=note) file.save() def message(): pass URL = "http://api.pownce.com/2.0/" user ="zodman" class TZ(datetime.tzinfo): def utcoffset(self,dt): return datetime.timedelta(hours=-5) def dst(self,dt): return self.utcoffset(dt) # load the pownce posts p = urllib.urlopen(URL+"note_lists/zodman.json") json_response = p.read() notes = simplejson.loads(json_response) for i in notes['notes']: if 'sender' in i: del i['sender'] if 'app' in i: del i['app'] functions = { "link": lambda i,note: link(i,note), "message": lambda i,note: message(), "event": lambda i,note: event(i,note), "file": lambda i,note: file(i,note) } dt = datetime.datetime.fromtimestamp(i['timestamp'],TZ()) df = DateFormat(dt) defaults = {"body":i["body"], "permalink":i["permalink"]} note, created = PownceNote.objects.get_or_create(pownce_id=i['id'],date=df.format("Y-m-d H:i"),defaults=defaults) if created: functions[i["type"]](i,note)
Well and show it on the template...
{% extends "index.html" %} {% load markup %} {% load zodytag %} {% block contenido %} {% for j in latest %} {% ifequal j.content_type.name "entrada"%} {%with j.content_object as e %} <div class="entrada-all"> <span class="round-up-left"></span> <span class="round-up-right"></span> <div class="entrada"> <div class="x-small float-right" style="width:100px;height:20px">{{e.fecha|date}} </div> <h2> {{e.titulo}} </h2> {{e.contenido|markdown:"codehilite" }} <div class="left x-small categorias"> {%for i in e.categoria.all %} <a href="{{i.permalink}}"> {{i.nombre}}</a> {% endfor %} </div> <div class="entrada-links"> <a href="{{e.permalink}}">Direct Link </a> | <span class="a" onclick="addComment('{{e.pk}}')"> Comment ({% count_comment e.pk %}) </span> </div> </div> </div> {% endwith %} {%endifequal%} {% ifequal j.content_type.name "pownce note"%} {% with j.content_object as e %} <div class="pownce"> <span class="type"> {{e.get_type}}</span> <span class="permalink"> <a href="{{e.permalink}}">permalink</a></span> <div class="content"> {{e.body|truncatewords_html:20|urlize}} </div> <div class="content-type"> {% ifequal e.get_type "Link" %} {% for i in e.powncelink_set.all %} <div class="link"> <img src="/static/images/link.gif"><a href="{{i.url}}">{{ i.url|urlizetrunc:32 }}</a> </div> {% endfor %} {% endifequal %} {% ifequal e.get_type "Event" %} {% for i in e.pownceevent_set.all %} <div class="event"> <img src="/static/images/event.gif"> <a href="{{i.ical}}"> {{i.name}} / {{i.location}} / {{i.date|date:"Y F d"}} </a> </div> {% endfor %} {% endifequal %} {% ifequal e.get_type "File" %} {% for i in e.powncefile_set.all %} <div class="file"> <img src="/static/images/file.gif"> <a href="{{e.permalink}}"> {{i.name}} </a> </div> {% endfor %} {% endifequal %} </div> </div> {% endwith %} {% endifequal %} <div style="height:20px;"></div> {% endfor %} {% endblock %}
I think this not the best way for show it but works for me
well if you have questions search me on irc.freenode.org or get my code on http://zodyblog.googlecode.com
the next to do, make a reusable app with this.
python break the switch paradigm
Today im want to implement a pownce notes on my blog like jacobian haves.
Im really not use a switch statement on python only put a if else nodes.
So i found how python break the paradigm of switch
def link(): print "link" def message( ): print "msg" def event( ): print "event" def file( ): print "juaz" functions = { "link": link(), "message":message(), "event":event(), "file": file() } dofunc = functions["event"] dofunc()
WTF ?? where is the
switch( var ){ case "event": break; default: break; }
pydoc the python documentation tool
Im found this now, is a very but very usefull command for seen the documentation of python
You can use it:
$ pydoc <module>
And it show you a output of >>> help(<module>) on python prompt.
oooooh This not all. You can Up a webserver for seen documentations of all packages installed on your python libs.
$ sudo pydoc -p 8001
pydoc server ready at http://localhost:8001/
@zodman: prox chingadazo facebook app para dar chingadazos a tus compañeros!


