Skip to content

Instantly share code, notes, and snippets.

View tseaver's full-sized avatar

Tres Seaver tseaver

View GitHub Profile
@tseaver
tseaver / generate_manifest_from_git.sh
Created May 28, 2013 18:11
Git pre-commit hook to generate / update distutils' MANIFEST.in file using 'git ls-files'.
#!/bin/sh
#=============================================================================
# Generate distutils' MANIFEST.in from the checked-in contents of a Git repo.
#
# Symlink this script into your Git clone as '.git/hooks/pre-commit'
# After that point, any commit will cause 'MANIFEST.in' to be generated in
# the root of the clone. The *second* commit will update the file to name
# itself (not a bug, just an oddity, as distutils includes MANIFEST.in if
# it is present, no matter what).
#=============================================================================
@tseaver
tseaver / reproduce.py
Created June 7, 2013 01:13
Show how trunk ZODB creates unpicklable objects on Py3k.
from datetime import datetime
from BTrees.OOBTree import OOBTree
import transaction
from ZODB import DB
WORKING = datetime(5375, 12, 31, 23, 59, 59)
FAILING = datetime(5376, 12, 31, 23, 59, 59)
LASTONE = datetime(9999, 12, 31, 23, 59, 59)
@tseaver
tseaver / gist:5746072
Created June 10, 2013 01:58
Test that repoze.retry allows lazy call of 'start_response'
--- a/repoze/retry/tests.py
+++ b/repoze/retry/tests.py
@@ -131,6 +131,16 @@ class RetryTests(unittest.TestCase, CEBase):
('200 OK', _MINIMAL_HEADERS, None))
self.assertEqual(result, [b'hello'])
+ def test_conflict_not_raised_start_response_called_at_first_chunk(self):
+ application = LazyApplication(conflicts=1)
+ retry = self._makeOne(application, tries=4,
+ retryable=(self.ConflictError,))
@tseaver
tseaver / with_mapping.py
Created January 9, 2014 16:18
Demonstrate https://github.com/zopefoundation/persistent/issues/3. The first file shows that persistent.mapping.PersistentMapping does *not* call its base class '__init__()' via 'super()'; the second shows that persistent.Persistent does.
from persistent.mapping import PersistentMapping
class Base1(object):
def __init__(self):
super(Base1, self).__init__()
print('Base1')
class Base2(object):
def __init__(self):
super(Base2, self).__init__()
from ZODB import DB
from BTrees.IIBTree import IIBTree
import transaction
def populate_tree():
db = DB('fuckme.fs')
connection = db.open()
root = connection.root()
tree = root['tree'] = IIBTree()
for i in xrange(1000000):
@tseaver
tseaver / gist:aae984fc4720ed29e573
Created September 22, 2014 19:40
oauth2client Py3k check
$ /opt/Python-3.3.3/bin/virtualenv /tmp/oauthclient-py3k
Using base prefix '/opt/Python-3.3.3'
New python executable in /tmp/oauthclient-py3k/bin/python3
Also creating executable in /tmp/oauthclient-py3k/bin/python
Installing Setuptools..............................................................................................................................................................................................................................done.
Installing Pip.....................................................................................................................................................................................................................................................................................................................................done.
$ /tmp/oauthclient-py3k/bin/pip
pip pip-3.3
$ /tmp/oauthclient-py3k/bin/pip install oauth2client
Downloading/unpacking oauth2client
@tseaver
tseaver / gist:0531a23cf6ca58fefcea
Created September 22, 2014 19:44
protobuf Py3K test
$ /opt/Python-3.3.3/bin/virtualenv /tmp/protobuf-py3k
Using base prefix '/opt/Python-3.3.3'
New python executable in /tmp/protobuf-py3k/bin/python3
Also creating executable in /tmp/protobuf-py3k/bin/python
Installing Setuptools..............................................................................................................................................................................................................................done.
Installing Pip.....................................................................................................................................................................................................................................................................................................................................done.
$ /tmp/protobuf-py3k/bin/pip install protobuf
Downloading/unpacking protobuf
Downloading protobuf-2.6.0.tar.gz (187kB): 187kB downloaded
Running setup.py egg_info for package protobuf
import os
import shutil
import subprocess
import sys
import tarfile
import time
import zipfile
import tempfile
@tseaver
tseaver / tox_output
Created October 28, 2014 19:59
`tox -e coveralls` failure
$ tox --recreate -e coveralls
GLOB sdist-make: /home/tseaver/projects/agendaless/Google/src/foobar/setup.py
coveralls recreate: /home/tseaver/projects/agendaless/Google/src/foobar/.tox/coveralls
coveralls installdeps: nose, unittest2, coverage, nosexcover, coveralls
coveralls inst: /home/tseaver/projects/agendaless/Google/src/foobar/.tox/dist/gcloud-0.02.2.zip
coveralls runtests: PYTHONHASHSEED='1276888446'
coveralls runtests: commands[0] | nosetests --with-xunit --with-xcoverage --cover-package=gcloud --nocapture --cover-erase --cover-tests --cover-branches
ERROR: InvocationError: could not find executable 'nosetests --with-xunit --with-xcoverage --cover-package=gcloud --nocapture --cover-erase --cover-tests --cover-branches'
coveralls runtests: commands[1] | coveralls
You have to provide either repo_token in .coveralls.yml, or launch via Travis
@tseaver
tseaver / gist:107797eaeaff70183d37
Created October 31, 2014 04:16
Borked ACL APIs on tseaver:151-163-use_acl_endpoints branch
>>> pp(key.metadata)
{u'bucket': u'tseaver-acl_test',
u'contentType': u'text/plain',
u'crc32c': u'gxU05g==',
u'etag': u'CNCAufqB1sECEAE=',
u'generation': u'1414728392786000',
u'id': u'tseaver-acl_test/test_file.txt/1414728392786000',
u'kind': u'storage#object',
u'md5Hash': u'JzS0T3kN66gC8V8yS/mI3Q==',
u'mediaLink': u'https://www.googleapis.com/download/storage/v1/b/tseaver-acl_test/o/test_file.txt?generation=1414728392786000&alt=media',