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 get_callable_name(func): | |
""" | |
Returns the best available display name for the given function/callable. | |
:rtype: str | |
""" | |
# the easy case (on Python 3.3+) | |
if hasattr(func, '__qualname__'): | |
return func.__qualname__ |
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
from sqlalchemy import create_engine, Table, Column, Integer, String, UniqueConstraint | |
from sqlalchemy.ext.declarative import declarative_base | |
engine = create_engine('postgresql:///testdb', echo=True) | |
Base = declarative_base() | |
SALT = dict( | |
phrase=64, | |
bytes=32, | |
) |
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
Error in sys.excepthook: | |
Traceback (most recent call last): | |
File "__pyclasspath__/etikettu/errorhandler.py", line 63, in exceptHook | |
UnboundLocalError: local variable 'traceback' referenced before assignment | |
Original exception was: | |
TypeError: canImport() takes exactly 3 arguments (2 given) |
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
#!/bin/sh | |
set -e | |
# Converts a Jython standalone jar into something usable with Java Web Start | |
if [ -z $1 ]; then | |
echo "Please give the path to the standalone jar as the first argument." | |
exit 1 | |
fi | |
CURRDIR=$(pwd) |
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 asyncio | |
async def execute(): | |
process = await asyncio.create_subprocess_exec( | |
"timeout", "0.1", "cat", "/dev/urandom", stdout=asyncio.subprocess.PIPE) | |
while True: | |
data = await process.stdout.read(65536) | |
print('read %d bytes' % len(data)) |
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
from sqlalchemy.orm.util import object_mapper | |
def get_primary_key(obj): | |
"""Returns the primary key of the given persistent object.""" | |
mapper = object_mapper(obj) | |
pk = mapper.primary_key_from_instance(obj) | |
return pk[0] if len(pk) == 1 else pk |
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
# Install asphalt-wamp first: | |
# pip install git+https://github.com/asphalt-framework/asphalt-wamp.git@932183440a064 | |
from pprint import pprint | |
from asphalt.core import Context, run_application, ContainerComponent | |
def handle_event(ctx, event): | |
pprint(event) |
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
FROM debian:jessie | |
ARG CROSSBAR_VERSION | |
ARG PYPY_VERSION=5.7.1 | |
ARG PYPY_SHA256SUM=2abaa54d88c9b70b64c37083e7e430a1d3a8f78f8de92e484a988b7aca1e50a7 | |
# install dependencies and Crossbar.io | |
RUN apt-get update \ | |
&& apt-get install -y --no-install-recommends \ | |
ca-certificates \ |
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 codecs | |
import json | |
import sys | |
from base64 import b64decode, b64encode | |
from codecs import CodecInfo | |
from functools import partial | |
from json import JSONDecoder, scanner | |
import six |
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
[metadata] | |
name = wampproto | |
description = WAMP (Web Application Message Protocol) state-machine based protocol implementation | |
long_description = file: README.rst | |
author = Alex Grönholm | |
author_email = [email protected] | |
url = https://github.com/agronholm/wampproto | |
license = MIT | |
license_file = LICENSE | |
keywords = wamp, websockets |