Skip to content

Instantly share code, notes, and snippets.

@theladyjaye
theladyjaye / gist:442d176a93b65c644f14
Last active June 12, 2018 19:47 — forked from FigBug/gist:4947379
Redirecting embedded Python’s I/O
Redirecting embedded Python’s I/O
Posted on 2012-4-13 by mvasilkov
When using Python for application scripting, more often than not you want to redirect interpreter’s input/output to the embedding program. This is how it’s done with the Python/C API:
PyObject *sys = PyImport_ImportModule("sys");
PyObject *out = PyFile_FromString("python_out", "w+");
PyObject_SetAttrString(sys, "stdout", out);
Pretty intuitive, right? Now embedded Python’s stdout points to the newly created file, python_out. Working with the script’s output from C is also trivial:
@theladyjaye
theladyjaye / build_gitolite_deb.sh
Created October 4, 2012 21:49 — forked from justone/build_gitolite_deb.sh
gitolite v3 debian package
#!/bin/bash
# install rvm
aptitude install -y curl libz-dev
curl -L https://get.rvm.io | bash -s stable --ruby
source /usr/local/rvm/scripts/rvm
gem install fpm
# git clone
aptitude install -y git