- GitHub Staff
- https://www.peterbe.com
- @peterbe
This file contains 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
class TEST: | |
def test_foo(self): | |
self.assertEqual('some very long string bla bla bla' in response.headers['Something']) |
This file contains 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
#!/usr/bin/env python | |
import os | |
import site | |
import sys | |
ROOT = os.path.dirname(os.path.abspath(__file__)) | |
path = lambda *a: os.path.join(ROOT,*a) | |
# Adjust the python path and put local packages in front. |
This file contains 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
try: | |
from settings_local import * | |
except ImportError: | |
from settings_base import * |
This file contains 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
#!/usr/bin/env python | |
def main(*args): | |
return 0 | |
if __name__ == '__main__': | |
import sys | |
sys.exit(main(*sys.argv[1:])) |
This file contains 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
#!/usr/bin/env python | |
""" | |
Usage: licence_check.py [directory] | |
Finds all checked in files that suspiciously lack a MPL licensing header. | |
Options: | |
-h, --help show this help message and exit | |
(c) peterbe@mozilla.com, June 2011 | |
""" |
This file contains 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
class dict_plus(dict): | |
def __init__(self, *args, **kwargs): | |
if 'collection' in kwargs: # excess we don't need | |
kwargs.pop('collection') | |
dict.__init__(self, *args, **kwargs) | |
self._wrap_internal_dicts() | |
def _wrap_internal_dicts(self): | |
for key, value in self.items(): |
This file contains 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
def main(): # pragma: no cover | |
tornado.options.parse_command_line() | |
http_server = tornado.httpserver.HTTPServer(Application()) | |
print "Starting tornado on port", options.port | |
http_server.listen(options.port) | |
try: | |
tornado.ioloop.IOLoop.instance().start() | |
except KeyboardInterrupt: |
This file contains 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 functools | |
import urllib | |
import urlparse | |
# taken from tornado.web.authenticated | |
def authenticated_plus(extra_check): | |
"""Decorate methods with this to require that the user be logged in.""" | |
def wrap(method): | |
@functools.wraps(method) | |
def wrapper(self, *args, **kwargs): |
This file contains 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 functools | |
import urllib | |
import urlparse | |
# taken from tornado.web.authenticated | |
def authenticated_plus(extra_check): | |
"""Decorate methods with this to require that the user be logged in.""" | |
def wrap(method): | |
@functools.wraps(method) | |
def wrapper(self, *args, **kwargs): |
This file contains 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
""" | |
tornado_static is a module for displaying static resources in a Tornado web | |
application. | |
It can take care of merging, compressing and giving URLs ideal renamings | |
suitable for aggressive HTTP caching. | |
(c) mail@peterbe.com | |
""" |