This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@classmethod | |
def factura_mas_reciente(cls): | |
"""arroja el folio de la factura mas reciente ( folio mayor )""" | |
try: | |
return session.query(cls).order_by(cls.folio.desc()).first().folio | |
except: | |
return 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto, sys, json | |
c = boto.connect_iam() | |
user, bucket = sys.argv[1:] | |
user_policy = dict( Statement = [ dict(Effect = "Allow", Action = ["s3:ListBucket",] , Resource = "arn:aws:s3:::{}".format( bucket ), Condition = dict( StringLike = { "s3:prefix" : "/home/{}/*".format(user)} )),]) | |
response = c.put_user_policy( user, "ListBucketFor{}{}Policy".format(user[0].upper(),user[1:]), json.dumps(user_policy) ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import redis | |
import sys | |
import json | |
r = redis.Redis() | |
k = r.incr("nbb_key") | |
r.rpush("nbb_queue",k) | |
nk = "P{:010d}".format(k) | |
msg = "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Traceback (most recent call last): | |
File "basic_test.py", line 2, in <module> | |
from repoze.profile.profiler import AccumulatingProfileMiddleware | |
File "/Users/director/dev/virtual/profile_flask/lib/python2.7/site-packages/repoze/profile/profiler.py", line 26, in <module> | |
import meld3 | |
File "/Users/director/dev/virtual/profile_flask/lib/python2.7/site-packages/meld3/__init__.py", line 2, in <module> | |
from meld3 import parse_xml | |
File "/Users/director/dev/virtual/profile_flask/lib/python2.7/site-packages/meld3/meld3.py", line 27, in <module> | |
from xml.etree.ElementTree import fixtag | |
ImportError: cannot import name fixtag |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pip.util import get_installed_distributions | |
whatIwant = False # set this to True if in a virtualenv | |
for x in get_installed_distributions(local_only = whatIwant): | |
print x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python 2.7 (r27:82508, Jul 3 2010, 21:12:11) | |
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import wx | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
File "/usr/local/lib/wxPython-unicode-2.8.11.0/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/__init__.py", line 45, in <module> | |
from wx._core import * | |
File "/usr/local/lib/wxPython-unicode-2.8.11.0/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/_core.py", line 4, in <module> | |
import _core_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, glob | |
from flask import Flask, request, redirect, url_for, render_template | |
from werkzeug import SharedDataMiddleware | |
from werkzeug import secure_filename | |
import subprocess | |
from subprocess import check_output, CalledProcessError | |
from bdata import UPLOAD_FOLDER | |
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif']) | |
app = Flask(__name__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
==> webmachine (get-deps) | |
Pulling mochiweb from {hg,"http://bitbucket.org/basho/mochiweb","tip"} | |
requesting all changes | |
adding changesets | |
adding manifests | |
adding file changes | |
added 123 changesets with 274 changes to 66 files | |
62 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
ERROR: Dependency dir /Users/director/dev/webmachine/deps/mochiweb does not satisfy version regex 1.7.0. | |
make: *** [deps] Error 1 |