Skip to content

Instantly share code, notes, and snippets.

View batok's full-sized avatar

Domingo Aguilera batok

  • Consultant
  • Guadalajara, Mexico
  • X @batok
View GitHub Profile
gunicorn_paster development.ini
2010-05-13 18:20:24 [21304] [ERROR] Retrying in 1 second.
2010-05-13 18:20:25 [21304] [ERROR] Retrying in 1 second.
2010-05-13 18:20:26 [21304] [ERROR] Retrying in 1 second.
2010-05-13 18:20:27 [21304] [ERROR] Retrying in 1 second.
2010-05-13 18:20:28 [21304] [ERROR] Retrying in 1 second.
2010-05-13 18:20:29 [21304] [ERROR] Can't connect to ('127.0.0.1', 8000)
from cmd2 import Cmd
import s3accounts
from boto.s3.connection import S3Connection
class Shell(Cmd):
prompt = "sc2s3>"
def __init__(self, connection):
Cmd.__init__(self)
self.conn = connection
self.bucket = s3accounts.preferred_bucket
self.prompt = "sc2s3_{0}> ".format( self.bucket)
@batok
batok / cfd.py
Created April 30, 2010 20:20
Parte que emite reporte mensual a Hacienda de CFDs
ano = wx.GetTextFromUser(u"Indique año","Reporte")
mes = wx.GetTextFromUser(u"Indique mes","Reporte")
foo, ultimo_dia = calendar.monthrange(int(ano),int(mes))
REPORTE = "{2}{0:02d}{1}.txt".format(int(mes),ano,rfc)
with open(REPORTE,"w") as f:
for factura in model.session.query(model.Factura).filter( model.Factura.fecha.between(datetime(int(ano),int(mes),1), datetime(int(ano),int(mes),ultimo_dia,23,59,59))).all():
subtotal = "{0:12.2f}".format(factura.subtotal).strip()
iva = "{0:12.2f}".format(factura.iva).strip()
f.write("|{0}||{1}|{2:4d}{3}|{4}|{5}|{6}|1|I||||\n".format(factura.mi_cliente.rfc, factura.folio, factura.ano_aprobacion, factura.aprobacion,factura.fecha_reporte, subtotal, iva ))
os.system("open {0}".format(REPORTE))
@batok
batok / gist:380833
Created April 27, 2010 15:03
Calling a skype user from python through the browser
import os
SKYPE_DESTINATION = "placeusernamehere_or_number_if_you_have_skype_credit"
with open("skype.html", "w") as f:
contents = """
<html>
<head>
<script>
window.location="skype:{0}?call";
</script>
</head>
@expose()
def sns(self,*args, **kwargs):
try:
d = json.loads(request.body)
except:
d = dict()
d[u"Message"] = "Dummy Message"
m = d.get(u"Message", "").encode("utf-8")
t = Twitter()
t.setauth(TW_USER,TW_PWD)
#nada aun
class ToasterBox(object):
@classmethod
def play(cls, win, mensaje):
tb = TB.ToasterBox(win,TB.TB_SIMPLE,TB.DEFAULT_TB_STYLE, TB.TB_ONCLICK)
tb.SetPopupSize((250,200))
tb.SetPopupPosition((500,500))
tb.SetPopupPauseTime(4000)
tb.SetPopupScrollSpeed(8)
@batok
batok / gist:314942
Created February 25, 2010 19:28
Ejemplo de dectools
@post("self.name and self.price >= 0 and Item.tax_rate >= 0", globals())
def __init__(self, name, price):
self.name = name
self.price = price
def _invariant(self):
assert self.name not in ("Swiss", "Cheddar")
assert self.price > 0
@pre("adjustment < 0")
prnt("*Extra parameters")
def security_level(function, args, kwargs, level):
prnt("You are level", level)
if level == "admin":
return True
elif "override_security" in kwargs:
del kwargs['override_security']
return True
else:
return False
def logger(f, name=None):
# Closure to remember our name and function objects
if name is None:
name = f.func_name
def wrapped(*args, **kwargs):
#print "Calling", name, args, kwargs
log_queue.append((name, xdt.now().timetuple()[:6]))
result = f(*args, **kwargs)
#print "Called", name, args, kwargs, "returned", repr(result)
File "prueba.py", line 3, in <module>
engine = sa.create_engine("mssql+pymssql://foo/bar@host/pruebas" )
File "/home/smartics/myenv/src/sqlalchemy/lib/sqlalchemy/engine/__init__.py", line 223, in create_engine
return strategy.create(*args, **kwargs)
File "/home/smartics/myenv/src/sqlalchemy/lib/sqlalchemy/engine/strategies.py", line 65, in create
dialect = dialect_cls(**dialect_args)
File "/home/smartics/myenv/src/sqlalchemy/lib/sqlalchemy/dialects/mssql/pymssql.py", line 25, in __init__
super(MSSQLDialect_pymssql, self).__init__(**params)
NameError: global name 'MSSQLDialect_pymssql' is not defined