Skip to content

Instantly share code, notes, and snippets.

View lvh's full-sized avatar

lvh lvh

View GitHub Profile
@lvh
lvh / manhole.py
Created September 15, 2012 11:10
Manhole and Axiom demo
from axiom import attributes, item, store
import jinja2
import sys
from twisted.cred import checkers, portal
from twisted.conch import manhole, manhole_ssh
from twisted.internet import reactor
from twisted.python import log
from twisted.web import resource, server
from twisted.protocols import amp
class NestedAMPBox(amp.AmpList):
def fromStringProto(self, inString, proto):
value, = amp.AmpList.fromStringProto(self, inString, proto)
return value
def toStringProto(self, inObject, proto):
return amp.AmpList.toStringProto(self, [inObject], proto)
class ComposedLocator(object):
"""
A responder locator that consists of other locators.
"""
interface.implements(amp.IResponderLocator)
class __metaclass__(type):
def __new__(meta, name, bases, attrs):
"""
Makes sure every subclass gets its own set of locator classes.
@lvh
lvh / client.py
Created July 6, 2012 08:37
Twisted file upload
import random
import StringIO
from zope import interface
from twisted.internet import abstract, defer, reactor
from twisted.web import client, http_headers, iweb
class _FileProducer(object): # pragma: no cover
"""
class C1(object):
class __metaclass__(type):
def __new__(meta, name, bases, attrs):
attrs["sentinel"] = object()
return type(name, bases, attrs)
class C2(object):
class __metaclass__(type):
def __new__(meta, name, bases, attrs):
attrs["sentinel"] = object()
"""
AMP over WebSockets support.
"""
import json
import txws
from twisted.internet import defer, protocol
from twisted.python import log
meese is a built-in package.
Status: Built-in.
Summary: protect the impressionable young minds of America
Adds a hook to protect the impressionable young minds of America
from reading certain files in the Emacs distribution using Emacs.
This file is named after Ed Meese, the US Attorney General