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
#!/bin/env python
# -*- coding: iso-8859-15 -*-
from sqlalchemy import create_engine, ForeignKey, MetaData, Column, Integer, String, Numeric, DateTime, Boolean
from sqlalchemy.orm import mapper, sessionmaker, validates, relation, synonym
from sqlalchemy.ext.declarative import declarative_base
from datetime import datetime
from factura import config as config_ini
Base = declarative_base()
engine = create_engine(config_ini["DB"]["url"])
#this snippet will let
#assign full access RWD to a specific bucket to an already created user ( with iam )
# works with python 2.7
import boto, sys, json
c = boto.connect_iam()
if len(sys.argv) == 2:
c.get_all_user_policies(sys.argv[1])
# works with python 2.7
import boto, sys, json
c = boto.connect_iam()
user = sys.argv[1]
policy_name = "list_all_buckets_{}".format( user )
policy = json.dumps(dict( Statement = [ dict(Effect = "Allow", Action = "s3:ListAllMyBuckets" , Resource = "arn:aws:s3:::*"),]))
import boto, sys
c = boto.connect_s3()
b = c.get_bucket(sys.argv[1], validate = False)
for key in b.get_all_keys():
print key.name, key.etag
import sys, boto
from hashlib import md5
try:
bucket, key_name, local_name = sys.argv[1:]
except:
sys.exit("wrong arguments")
c = boto.connect_s3()
b = c.get_bucket(bucket, validate = False )
class Factura(Base):
__tablename__ = "facturas"
id = Column( Integer, primary_key = True )
folio = Column( Integer, unique = True )
fecha = Column( DateTime )
aprobacion = Column( Integer )
ano_aprobacion = Column( Integer )
certificado = Column(String(20))
cliente = Column( Integer , ForeignKey( "clientes.id"))
porcentaje_iva = Column( Numeric(6,3))
import wx.lib.agw.gradientbutton as GB
import wx.lib.agw.genericmessagedialog as GMD
class GMDialog(object):
@classmethod
def show(cls, win, mensaje, titulo):
dlg = GMD.GenericMessageDialog(win, mensaje, titulo, wx.OK | ( wx.ICON_INFORMATION + GMD.GMD_USE_GRADIENTBUTTONS ) )
val = dlg.ShowModal()
dlg.Destroy()
return val
if c[1] == "fecha_iso":
wx.StaticText(self.pane,-1,"")
f_button = GB.GradientButton(self.pane,-1,None,"Editar Fecha Especial")
self.f_iso = text
wx.StaticText(self.pane,-1,"Porcentajes")
porc_button = GB.GradientButton(self.pane,-1,None,"Cambiar")
wx.StaticText(self.pane,-1,"Partidas")
subpane = sc.SizedPanel(self.pane,-1)
subpane.SetSizerType("horizontal")
@batok
batok / gist:647342
Created October 26, 2010 17:21
ultimate.py
def anotaciones(self):
lc = self.lc
lc.ClearAll()
bg1 = wx.Colour(239,235,239)
bg2 = wx.Colour(255,207,99)
title = u"#,Fecha, Anotación"
for i, colTitle in enumerate(title.split(",")):
lc.InsertColumn(i,colTitle)
x = 0
for anotacion in model.session.query( model.Anotacion ).filter( model.Anotacion.relacion == self.data).order_by( model.Anotacion.fecha_elaboracion.desc()):
class IniDialog(BaseDialog):
def AddControls(self):
lbox = gizmos.EditableListBox( self.pane, -1, u"Edición de INI", (100,100), (250,250))
with open("felec.ini") as f:
lineas = [ linea for linea in f.read().split("\n") if linea ]
lbox.SetStrings( lineas )