• Stars
    star
    160
  • Rank 234,703 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Capture C-level stdout/stderr in Python

Wurlitzer

Capture C-level stdout/stderr pipes in Python via os.dup2.

For more details on why this is needed, please read this blog post.

Install

pip install wurlitzer

Usage

Capture stdout/stderr in pipes:

from wurlitzer import pipes

with pipes() as (out, err):
    call_some_c_function()

stdout = out.read()

Capture stdout/stderr in StringIO:

from io import StringIO
from wurlitzer import pipes, STDOUT

out = StringIO()
with pipes(stdout=out, stderr=STDOUT):
    call_some_c_function()

stdout = out.getvalue()

Forward C-level stdout/stderr to Python sys.stdout/stderr, which may already be forwarded somewhere by the environment, e.g. IPython:

from wurlitzer import sys_pipes

with sys_pipes():
    call_some_c_function()

Or even simpler, enable it as an IPython extension:

%load_ext wurlitzer

To forward all C-level output to IPython during execution.

Acknowledgments

This package is based on stuff we learned with @takluyver and @karies while working on capturing output from the Cling Kernel for Jupyter.

Wurlitzer?!

Wurlitzer makes pipe organs. Get it? Pipes? Naming is hard.

More Repositories

1

findspark

Python
499
star
2

ipython_extensions

My IPython extensions
Python
424
star
3

nbextension-scratchpad

scratchpad extension for Jupyter notebook
JavaScript
184
star
4

clingkernel

Now part of Cling, no longer maintained here
Python
125
star
5

IPython-parallel-tutorial

tutorial materials for IPython.parallel
Python
109
star
6

allthekernels

A multiplexer kernel for Jupyter
Python
74
star
7

jupyterhub-pydata-2016

Jupyter Notebook
64
star
8

ligo-binder

Black holes!
Jupyter Notebook
61
star
9

appnope

Disable App Nap on OS X 10.9
Python
51
star
10

condamagic

%conda magic for IPython
Python
27
star
11

singlecell

Demo of Single-cell IPython webapps
JavaScript
27
star
12

archive-gitter

Python
25
star
13

jskernel

JavaScript
24
star
14

jupyterhub-demo

Demo deployment of JupyterHub
Python
20
star
15

binder-bokeh-server

Python
19
star
16

a2km

Assistant to the Kernel Manager
Ruby
18
star
17

profile_default

Python
17
star
18

pyzmq-py3k-examples

pyzmq examples updated for Python3 syntax
Python
15
star
19

asyncio-atexit

atexit, but for asyncio
Python
13
star
20

pydata-sv-14

Jupyter Notebook
12
star
21

nbstencilaproxy

Jupyter+DAR compatibility exploration
Jupyter Notebook
12
star
22

scipy-tutorial-2011

Parallel Computing in IPython tutorial, SciPy 2011
Python
11
star
23

.jupyter

Python
10
star
24

release-page

Python
10
star
25

ghost-backup

backup ghost blog
Ruby
10
star
26

tc-init

Kubernetes init container for bandwidth-shaping
Shell
9
star
27

restuser

Python
9
star
28

pypyjskernel

Python
9
star
29

PyCUDA

fork of http://git.tiker.net/trees/pycuda.git, for patches
Python
8
star
30

simula-tools-meetup

Jupyter Notebook
7
star
31

ghpro

Utilities for working with GitHub (IPython/Jupyter-related, mostly)
Python
7
star
32

fenics-binder

Jupyter Notebook
6
star
33

jupyterhub-swarm

Python
6
star
34

PyData2012

IPython.parallel tutorial for PyData 2012
Python
5
star
35

scrub-nb-outputs-pre-commit

scrub notebook outputs as a git pre-commit hook
Python
5
star
36

git-crypt-bin

Shell
5
star
37

jupyterhub-simula

Python
4
star
38

DnDTools

Python (WX) Item Card Generator for D&D (4e)
Python
4
star
39

dots

turn lines into dots
Go
4
star
40

git-checkpoints

Python
4
star
41

pybundled

Example of bundling a C library as a Python Extension
Python
4
star
42

sbw2016-jupyter

IPython and Jupyter tutorial for SBW 2016
Jupyter Notebook
4
star
43

all-my-pulls

JavaScript
4
star
44

jupyterhub-placeholder-autoscaler

Python
3
star
45

escapism

Python
3
star
46

jupyter-keepalive

Keep jupyter servers alive
TypeScript
3
star
47

git-stuff

Shell
3
star
48

simula-workshop

Jupyter Notebook
3
star
49

homebrew-python-frameworks

homebrew casks for Python.org installers
Ruby
3
star
50

jupyterhub-client

JupyterHub REST API client
Python
3
star
51

starclusterplugins

My plugins for starcluster
Python
3
star
52

binder-chapter-example

Dockerfile
3
star
53

ipython-cse17

IPython and Jupyter tutorial at SIAM CSE 17
Jupyter Notebook
3
star
54

migrate-issues

Ruby
3
star
55

cilogon-authenticator

Python
3
star
56

envreport

diff environments
Jupyter Notebook
3
star
57

phoenix

IPython Notebook + Phoenix demos
Python
2
star
58

sf-analytics-2015

2
star
59

hit-kernel

Python
2
star
60

binder-template-example

HTML
2
star
61

google-caja-bower

JavaScript
2
star
62

travis-wheels

A source of built travis wheels
2
star
63

pexnb

Entrypoint for launching notebooks with PEX
Python
2
star
64

binder-cpu-data

Jupyter Notebook
2
star
65

resbaz-2017

Jupyter Notebook
2
star
66

chpbench

Benchmarking for Configurable-HTTP-Proxy
Python
2
star
67

git-filter-branch-utils

Python
2
star
68

jupyterhub-bench

Jupyter Notebook
2
star
69

wheelhouse

Shell
2
star
70

aiotravis

asyncio travis API
Jupyter Notebook
2
star
71

nbbot

Python
2
star
72

simula-summer-school

Python
2
star
73

nbmelt

melt your notebooks if they don't get used!
Python
2
star
74

dashboard-workshop-repo

Jupyter Notebook
2
star
75

my-conda-recipes

Min's conda recipes
Shell
2
star
76

horizon-widera-2022

Rich Text Format
1
star
77

jupyterhub-stress-test

Jupyter Notebook
1
star
78

halide-conda

Shell
1
star
79

SCDMSPlot

Simple Plotting Utility for SCDMS dep data
Python
1
star
80

tutorials

Tutorials for IPython and PyZMQ
1
star
81

mytest

test repo for IN3110
Python
1
star
82

launchabel

Python
1
star
83

jupyterhub-yo-dawg

JupyterHub with JupyterHub as an OAuth provider
Python
1
star
84

nonofusedmadd

fix build errors on OS X 10.9 System Python
Python
1
star
85

test-action

JavaScript
1
star
86

py4science-notebooks

JavaScript
1
star
87

jupyterhub-images

build container images for JupyterHub
1
star
88

piphub

Python
1
star
89

baypiggies-2014-04-24

Python
1
star
90

smallest-binder

Attempts at different versions of the "smallest" image for Binder
Dockerfile
1
star
91

showpkg

Python
1
star
92

rupy

IPython presentation at RuPy 2013
Shell
1
star
93

junk

random junk
HTML
1
star
94

bananagrams

Jupyter Notebook
1
star
95

delft-visit

Python
1
star
96

rebound-binder

Jupyter Notebook
1
star
97

pytest-mpiexec

pytest plugin for running individual tests with mpi
Python
1
star
98

lumberjack

lumberjack IRC logbot & viewer
Python
1
star
99

odk-data

data for opendreamkit
Jupyter Notebook
1
star