A workflow for docker that separates build-time dependencies from run-time dependencies.
Create the image used for building apps.
docker build -t pybuilder pybuilder
Create the image used for running apps.
.PHONY: dbsetup clean_files clean_rabbit clean migrate dev js | |
# Both Python and Node programs will be put here. | |
BIN=$(shell dirname `which python`) | |
STATIC_DIR=mettle/static | |
JSX_DIR=$(STATIC_DIR)/jsx | |
# Our React components have dependencies on each other. This ordering is important. | |
JSX_MODULES=jobs targets runs pipelines services app | |
JSX_TARGETS=$(foreach module,$(JSX_MODULES),$(JSX_DIR)/$(module).js) |
from pyramid.config import Configurator | |
from pyramid.view import view_config | |
def main(global_config, **app_settings): | |
config = Configurator(settings=app_settings) | |
config.include('.model') | |
config.scan(__name__) | |
return config.make_wsgi_app() | |
from pyramid.interfaces import IRequest | |
from zope.interface.registry import Components | |
def includeme(config): | |
config.add_request_method(find_service) | |
config.add_request_method(lambda _: Components(), 'service_cache', | |
reify=True) | |
config.add_directive('register_service', register_service) | |
config.add_directive('register_service_factory', register_service_factory) |
from sqlalchemy import Column, Integer, create_engine | |
from sqlalchemy.ext.declarative import declarative_base | |
Base = declarative_base() | |
# a model | |
class Thing(Base): | |
__tablename__ = 'thing' | |
id = Column(Integer, primary_key=True) |
A workflow for docker that separates build-time dependencies from run-time dependencies.
Create the image used for building apps.
docker build -t pybuilder pybuilder
Create the image used for running apps.
#! usr/bin/python | |
""" | |
A bot for solving Sudoku Puzzles. It uses PyUserInput for cross-platform | |
keyboard and mouse support. It supplies the pymouse and pykeyboard modules. | |
Using OCR may be a upcoming feature. | |
The first step is to define the game window so that the script can click and | |
type appropriately. |
(This gist is pretty old; I've written up my current approach to the Pyramid integration on this blog post, but that blog post doesn't go into the transactional management, so you may still find this useful.)
I've created a Pyramid scaffold which integrates Alembic, a migration tool, with the standard SQLAlchemy scaffold. (It also configures the Mako template system, because I prefer Mako.)
I am also using PostgreSQL for my database. PostgreSQL supports nested transactions. This means I can setup the tables at the beginning of the test session, then start a transaction before each test happens and roll it back after the test; in turn, this means my tests operate in the same environment I expect to use in production, but they are also fast.
I based my approach on [sontek's blog post](http://sontek.net/blog/
import sys | |
import socket | |
import string | |
import os | |
import threading | |
import time | |
import random | |
windowtitle = "Nezzbot IRC Client" | |
from os import system | |
system("title "+windowtitle) |
import collections | |
import sqlalchemy.types | |
class Hstore(sqlalchemy.types.UserDefinedType, sqlalchemy.types.MutableType): | |
"""The ``hstore`` type that stores a dictionary. It can take an any | |
instance of :class:`collections.Mapping`. | |
It can be extended to store other types than string e.g.:: |