Skip to content

Instantly share code, notes, and snippets.

View ScottSturdivant's full-sized avatar

Scott Sturdivant ScottSturdivant

View GitHub Profile
@inlineCallbacks
def do_something():
data = yield get(url)
if 'some val' in data.content:
data = yield get(another_url)
defer.returnValue(data)
# Is this the equivalent way of describing this with regular callbacks?
class Client(object):
@inlineCallbacks
def login(self):
login = yield get('/login/')
self.token = login['token']
@inlineCallbacks
def poll_work(self):
while True:
__________________________ test_group_info_no_members __________________________
client = <tests.utils.FlaskTestClient object at 0x7f86d03100d0>
stripe_invoice = <Mock name='stripe_invoice' spec='Invoice' id='140216995219792'>
def test_group_info_no_members(client, stripe_invoice):
"""Can query a single group to see its info."""
group = GroupFactory()
url = URL + '/{}/info'.format(group.id)
rv = client.get(url)
with open('/tmp/out.txt', 'wa') as f:
f.write(rv.data)
@ScottSturdivant
ScottSturdivant / gist:1e4617a52b48c27d335c
Created October 15, 2014 14:49
sqlalchemy test isolation
@pytest.fixture(scope='session')
def db(app, request):
_db.create_all()
def teardown():
_db.session.remove()
_db.drop_all()
request.addfinalizer(teardown)
return _db
@ScottSturdivant
ScottSturdivant / Output
Created October 23, 2013 19:40
Using the git module in ansible to clone two repos into the same location. What should the expected outcome be? I would assume that the last git action to run would 'win'. In fact, nothing happens.
$ ansible-playbook -i hosts -v git_test.yml
PLAY [127.0.0.1] **************************************************************
GATHERING FACTS ***************************************************************
ok: [127.0.0.1]
TASK: [Clone the ansible canonical repo into /tmp/ansible_clone] **************
changed: [127.0.0.1] => {"after": "e34cde6bef26309919eb4da21c58a38b61770577", "before": null, "changed": true}
@ScottSturdivant
ScottSturdivant / main.yml
Created June 13, 2013 17:07
setting hostname via ansible
- name: Set the hostname in rc.conf
lineinfile: dest=/etc/rc.conf regexp="^hostname" line='hostname="{{ hostname }}"'
register: hostname
- name: Set the hostname
shell: hostname {{ hostname }}
when: hostname.changed
@ScottSturdivant
ScottSturdivant / Vagrantfile
Last active December 18, 2015 01:59 — forked from wutali/fabric.rb
Fabric provisioner for Vagrant 1.2
require_relative "plugins/provisioners/fabric/plugin.rb"
Vagrant.configure("2") do |config|
*snip*
config.vm.provision :fabric do |fab|
fab.tasks = ["setup_salt:kwarg=value"]
end
end